mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Detect feature level
This commit is contained in:
@@ -95,17 +95,18 @@ func (h handler) patreonCallback(c *gin.Context) {
|
||||
if user.Data.ID == creatorID {
|
||||
level = api.PodcasterFeature
|
||||
} else {
|
||||
amount := 0
|
||||
for _, item := range user.Included.Items {
|
||||
pledge, ok := item.(*patreon.Pledge)
|
||||
if ok {
|
||||
amount += pledge.Attributes.AmountCents
|
||||
pledge, err := h.hook.FindPledge(user.Data.ID)
|
||||
if err != nil {
|
||||
log.Printf("! can't find pledge for user %s: %v", user.Data.ID, err)
|
||||
} else {
|
||||
// Check pledge is valid
|
||||
if pledge.DeclinedSince.IsZero() && !pledge.IsPaused {
|
||||
// Check the amount of pledge
|
||||
if pledge.AmountCents >= 100 {
|
||||
level = api.ExtendedFeatures
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if amount >= 100 {
|
||||
level = api.ExtendedFeatures
|
||||
}
|
||||
}
|
||||
|
||||
identity := &api.Identity{
|
||||
|
Reference in New Issue
Block a user