2022-08-21 22:40:24 +00:00
|
|
|
package photo
|
|
|
|
|
|
|
|
import (
|
2022-08-26 04:21:46 +00:00
|
|
|
"code.nonshy.com/nonshy/website/pkg/config"
|
|
|
|
"code.nonshy.com/nonshy/website/pkg/models"
|
2022-08-21 22:40:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// QuoteForUser returns the current photo usage quota for a given user.
|
|
|
|
func QuotaForUser(u *models.User) (current, allowed int) {
|
|
|
|
// Count their photos.
|
2022-08-26 02:58:43 +00:00
|
|
|
count := models.CountPhotos(u.ID)
|
2022-08-21 22:40:24 +00:00
|
|
|
|
|
|
|
// What is their quota at?
|
|
|
|
var quota int
|
|
|
|
if !u.Certified {
|
|
|
|
quota = config.PhotoQuotaUncertified
|
|
|
|
} else {
|
|
|
|
quota = config.PhotoQuotaCertified
|
|
|
|
}
|
|
|
|
|
|
|
|
return int(count), quota
|
|
|
|
}
|