bleh
More API stuff. Lots of bleh. Really boring Also need to figure out a somewhat generic way for "requires ownership" permission and then a combinator for permissions
This commit is contained in:
parent
ffe3cf32ae
commit
1bb6cd8a70
8 changed files with 438 additions and 300 deletions
107
storage/roles.go
107
storage/roles.go
|
@ -39,30 +39,31 @@ type Role struct {
|
|||
IsBuiltIn bool
|
||||
|
||||
// --- User permissions ---
|
||||
CanSendMedia *bool
|
||||
CanSendCustomEmotes *bool
|
||||
CanSendCustomReactions *bool
|
||||
CanSendPublicNotes *bool
|
||||
CanSendLocalNotes *bool
|
||||
CanSendFollowerOnlyNotes *bool
|
||||
CanSendPrivateNotes *bool
|
||||
CanSendReplies *bool
|
||||
CanQuote *bool
|
||||
CanBoost *bool
|
||||
CanIncludeLinks *bool
|
||||
CanIncludeSurvey *bool
|
||||
CanFederateFedi *bool
|
||||
CanFederateBsky *bool
|
||||
CanSendMedia *bool // Local & remote
|
||||
CanSendCustomEmotes *bool // Local & remote
|
||||
CanSendCustomReactions *bool // Local & remote
|
||||
CanSendPublicNotes *bool // Local & remote
|
||||
CanSendLocalNotes *bool // Local & remote
|
||||
CanSendFollowerOnlyNotes *bool // Local & remote
|
||||
CanSendPrivateNotes *bool // Local & remote
|
||||
CanSendReplies *bool // Local & remote
|
||||
CanQuote *bool // Local only
|
||||
CanBoost *bool // Local only
|
||||
CanIncludeLinks *bool // Local & remote
|
||||
CanIncludeSurvey *bool // Local
|
||||
CanFederateFedi *bool // Local & remote
|
||||
CanFederateBsky *bool // Local
|
||||
|
||||
CanChangeDisplayName *bool
|
||||
CanChangeDisplayName *bool // Local
|
||||
|
||||
BlockedUsers []string `gorm:"type:bytes;serializer:gob"`
|
||||
CanSubmitReports *bool
|
||||
CanLogin *bool
|
||||
// Internal ids of accounts blocked by this role
|
||||
BlockedUsers []string `gorm:"type:bytes;serializer:gob"` // Local
|
||||
CanSubmitReports *bool // Local & remote
|
||||
CanLogin *bool // Local
|
||||
|
||||
CanMentionOthers *bool
|
||||
HasMentionCountLimit *bool
|
||||
MentionLimit *uint32
|
||||
CanMentionOthers *bool // Local & remote
|
||||
HasMentionCountLimit *bool // Local & remote
|
||||
MentionLimit *uint32 // Local & remote
|
||||
|
||||
// CanViewBoosts *bool
|
||||
// CanViewQuotes *bool
|
||||
|
@ -70,39 +71,39 @@ type Role struct {
|
|||
// CanViewCustomEmotes *bool
|
||||
|
||||
// --- Automod ---
|
||||
AutoNsfwMedia *bool
|
||||
AutoCwPosts *bool
|
||||
AutoCwPostsText *string
|
||||
ScanCreatedPublicNotes *bool
|
||||
ScanCreatedLocalNotes *bool
|
||||
ScanCreatedFollowerOnlyNotes *bool
|
||||
ScanCreatedPrivateNotes *bool
|
||||
AutoNsfwMedia *bool // Local & remote
|
||||
AutoCwPosts *bool // Local & remote
|
||||
AutoCwPostsText *string // Local & remote
|
||||
ScanCreatedPublicNotes *bool // Local & remote
|
||||
ScanCreatedLocalNotes *bool // Local & remote
|
||||
ScanCreatedFollowerOnlyNotes *bool // Local & remote
|
||||
ScanCreatedPrivateNotes *bool // Local & remote
|
||||
// Blocks all interactions and federation between users with the role and all included ids/handles
|
||||
// TODO: Decide whether this is a list of handles or of account ids
|
||||
// Handles would increase the load due to having to search for them first
|
||||
// while ids would require to store every single account mentioned
|
||||
// which could cause escalating storage costs
|
||||
DisallowInteractionsWith []string `gorm:"type:bytes;serializer:gob"`
|
||||
DisallowInteractionsWith []string `gorm:"type:bytes;serializer:gob"` // Local & remote
|
||||
|
||||
WithholdNotesForManualApproval *bool
|
||||
WithholdNotesBasedOnRegex *bool
|
||||
WithholdNotesRegexes []string `gorm:"type:bytes;serializer:gob"`
|
||||
WithholdNotesForManualApproval *bool // Local & remote
|
||||
WithholdNotesBasedOnRegex *bool // Local & remote
|
||||
WithholdNotesRegexes []string `gorm:"type:bytes;serializer:gob"` // Local & remote
|
||||
|
||||
// --- Admin perms ---
|
||||
// If set, counts as all permissions being set as given and all restrictions being disabled
|
||||
FullAdmin *bool
|
||||
CanAffectOtherAdmins *bool
|
||||
CanDeleteNotes *bool
|
||||
CanConfirmWithheldNotes *bool
|
||||
CanAssignRoles *bool
|
||||
CanSupressInteractionsBetweenUsers *bool
|
||||
CanOverwriteDisplayNames *bool
|
||||
CanManageCustomEmotes *bool
|
||||
CanViewDeletedNotes *bool
|
||||
CanRecoverDeletedNotes *bool
|
||||
CanManageAvatarDecorations *bool
|
||||
CanManageAds *bool
|
||||
CanSendAnnouncements *bool
|
||||
FullAdmin *bool // Local
|
||||
CanAffectOtherAdmins *bool // Local
|
||||
CanDeleteNotes *bool // Local
|
||||
CanConfirmWithheldNotes *bool // Local
|
||||
CanAssignRoles *bool // Local
|
||||
CanSupressInteractionsBetweenUsers *bool // Local
|
||||
CanOverwriteDisplayNames *bool // Local
|
||||
CanManageCustomEmotes *bool // Local
|
||||
CanViewDeletedNotes *bool // Local
|
||||
CanRecoverDeletedNotes *bool // Local
|
||||
CanManageAvatarDecorations *bool // Local
|
||||
CanManageAds *bool // Local
|
||||
CanSendAnnouncements *bool // Local
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -169,7 +170,8 @@ func (s *Storage) NewEmptyRole(name string) (*Role, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
newRole := Role{Name: name}
|
||||
// New roles have a priority of 1 by default
|
||||
newRole := Role{Name: name, Priority: 1}
|
||||
err = s.db.Create(&newRole).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -189,3 +191,16 @@ func (s *Storage) FindRoleByName(name string) (*Role, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Storage) FindRolesByNames(names []string) ([]Role, error) {
|
||||
roles := []Role{}
|
||||
err := s.db.Where("name IN ?", names).Find(&roles).Error
|
||||
switch err {
|
||||
case nil:
|
||||
return roles, nil
|
||||
case gorm.ErrRecordNotFound:
|
||||
return nil, ErrEntryNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue