23 lines
488 B
Go
23 lines
488 B
Go
package photo
|
|
|
|
import (
|
|
"code.nonshy.com/nonshy/website/pkg/config"
|
|
"code.nonshy.com/nonshy/website/pkg/models"
|
|
)
|
|
|
|
// QuoteForUser returns the current photo usage quota for a given user.
|
|
func QuotaForUser(u *models.User) (current, allowed int) {
|
|
// Count their photos.
|
|
count := models.CountPhotos(u.ID)
|
|
|
|
// What is their quota at?
|
|
var quota int
|
|
if !u.Certified {
|
|
quota = config.PhotoQuotaUncertified
|
|
} else {
|
|
quota = config.PhotoQuotaCertified
|
|
}
|
|
|
|
return int(count), quota
|
|
}
|