From 8191ad81878d045426caf29b5c2661fe6c4465cf Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 17 Sep 2024 19:31:54 +0800 Subject: [PATCH] :sparkles: Permission requirement of posting in realm --- pkg/internal/services/posts.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index c2b75ed..474da16 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -310,9 +310,11 @@ func NewPost(user models.Account, item models.Post) (models.Post, error) { if item.RealmID != nil { log.Debug().Uint("id", *item.RealmID).Msg("Looking for post author realm...") - _, err := GetRealmMember(*item.RealmID, user.ID) + member, err := GetRealmMember(*item.RealmID, user.ID) if err != nil { return item, fmt.Errorf("you aren't a part of that realm: %v", err) + } else if !item.Realm.IsCommunity && member.PowerLevel < 25 { + return item, fmt.Errorf("you need has power level above 25 of a realm or in a community realm to post") } }