Noah Petherbridge
71dfa76faa
* Add photo upload quotas. * Non-certified users can upload few photos; certified users more * Fix foreign key issues around deleting user profile photos for psql
23 lines
487 B
Go
23 lines
487 B
Go
package photo
|
|
|
|
import (
|
|
"git.kirsle.net/apps/gosocial/pkg/config"
|
|
"git.kirsle.net/apps/gosocial/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
|
|
}
|