More work on the api. Also auth middleware stuff
More work on the placeholder functions for the Linstrom API Additionally, started work on a slightly more sophisticated authentication control system And ran `go generate` again
This commit is contained in:
parent
b9c95a0297
commit
873f52d64f
14 changed files with 637 additions and 300 deletions
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
// For pretty printing during debug
|
||||
// If `go generate` is run, it'll generate the necessary function and data for pretty printing
|
||||
//go:generate stringer -type NoteTarget
|
||||
//go:generate stringer -type NoteAccessLevel
|
||||
|
||||
// What feed a note is targeting (public, home, followers or dm)
|
||||
type NoteAccessLevel uint8
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by "stringer -type NoteTarget"; DO NOT EDIT.
|
||||
// Code generated by "stringer -type NoteAccessLevel"; DO NOT EDIT.
|
||||
|
||||
package storage
|
||||
|
||||
|
@ -15,23 +15,23 @@ func _() {
|
|||
}
|
||||
|
||||
const (
|
||||
_NoteTarget_name_0 = "NOTE_TARGET_PUBLIC"
|
||||
_NoteTarget_name_1 = "NOTE_TARGET_HOME"
|
||||
_NoteTarget_name_2 = "NOTE_TARGET_FOLLOWERS"
|
||||
_NoteTarget_name_3 = "NOTE_TARGET_DM"
|
||||
_NoteAccessLevel_name_0 = "NOTE_TARGET_PUBLIC"
|
||||
_NoteAccessLevel_name_1 = "NOTE_TARGET_HOME"
|
||||
_NoteAccessLevel_name_2 = "NOTE_TARGET_FOLLOWERS"
|
||||
_NoteAccessLevel_name_3 = "NOTE_TARGET_DM"
|
||||
)
|
||||
|
||||
func (i NoteAccessLevel) String() string {
|
||||
switch {
|
||||
case i == 0:
|
||||
return _NoteTarget_name_0
|
||||
return _NoteAccessLevel_name_0
|
||||
case i == 2:
|
||||
return _NoteTarget_name_1
|
||||
return _NoteAccessLevel_name_1
|
||||
case i == 4:
|
||||
return _NoteTarget_name_2
|
||||
return _NoteAccessLevel_name_2
|
||||
case i == 8:
|
||||
return _NoteTarget_name_3
|
||||
return _NoteAccessLevel_name_3
|
||||
default:
|
||||
return "NoteTarget(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
return "NoteAccessLevel(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
}
|
|
@ -51,6 +51,8 @@ type Role struct {
|
|||
CanBoost *bool
|
||||
CanIncludeLinks *bool
|
||||
CanIncludeSurvey *bool
|
||||
CanFederateFedi *bool
|
||||
CanFederateBsky *bool
|
||||
|
||||
CanChangeDisplayName *bool
|
||||
|
||||
|
@ -75,7 +77,12 @@ type Role struct {
|
|||
ScanCreatedLocalNotes *bool
|
||||
ScanCreatedFollowerOnlyNotes *bool
|
||||
ScanCreatedPrivateNotes *bool
|
||||
DisallowInteractionsWith []string `gorm:"type:bytes;serializer:gob"`
|
||||
// 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"`
|
||||
|
||||
WithholdNotesForManualApproval *bool
|
||||
WithholdNotesBasedOnRegex *bool
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"gitlab.com/mstarongitlab/goutils/other"
|
||||
)
|
||||
|
||||
// Default role every user has. Defines sane defaults for a normal user
|
||||
// Will get overwritten by just about every other role due to every other role having higher priority
|
||||
var DefaultUserRole = Role{
|
||||
Name: "Default",
|
||||
Priority: 0,
|
||||
|
@ -19,10 +21,13 @@ var DefaultUserRole = Role{
|
|||
CanSendLocalNotes: other.IntoPointer(true),
|
||||
CanSendFollowerOnlyNotes: other.IntoPointer(true),
|
||||
CanSendPrivateNotes: other.IntoPointer(true),
|
||||
CanSendReplies: other.IntoPointer(true),
|
||||
CanQuote: other.IntoPointer(true),
|
||||
CanBoost: other.IntoPointer(true),
|
||||
CanIncludeLinks: other.IntoPointer(true),
|
||||
CanIncludeSurvey: other.IntoPointer(true),
|
||||
CanFederateFedi: other.IntoPointer(true),
|
||||
CanFederateBsky: other.IntoPointer(true),
|
||||
|
||||
CanChangeDisplayName: other.IntoPointer(true),
|
||||
|
||||
|
@ -32,7 +37,9 @@ var DefaultUserRole = Role{
|
|||
|
||||
CanMentionOthers: other.IntoPointer(true),
|
||||
HasMentionCountLimit: other.IntoPointer(false),
|
||||
MentionLimit: other.IntoPointer(uint32(math.MaxUint32)), // Set this to max, even if not used due to *HasMentionCountLimit == false
|
||||
MentionLimit: other.IntoPointer(
|
||||
uint32(math.MaxUint32),
|
||||
), // Set this to max, even if not used due to *HasMentionCountLimit == false
|
||||
|
||||
AutoNsfwMedia: other.IntoPointer(false),
|
||||
AutoCwPosts: other.IntoPointer(false),
|
||||
|
@ -59,7 +66,8 @@ var DefaultUserRole = Role{
|
|||
CanSendAnnouncements: other.IntoPointer(false),
|
||||
}
|
||||
|
||||
var fullAdminRole = Role{
|
||||
// Role providing maximum permissions
|
||||
var FullAdminRole = Role{
|
||||
Name: "fullAdmin",
|
||||
Priority: math.MaxUint,
|
||||
IsUserRole: false,
|
||||
|
@ -85,7 +93,9 @@ var fullAdminRole = Role{
|
|||
|
||||
CanMentionOthers: other.IntoPointer(true),
|
||||
HasMentionCountLimit: other.IntoPointer(false),
|
||||
MentionLimit: other.IntoPointer(uint32(math.MaxUint32)), // Set this to max, even if not used due to *HasMentionCountLimit == false
|
||||
MentionLimit: other.IntoPointer(
|
||||
uint32(math.MaxUint32),
|
||||
), // Set this to max, even if not used due to *HasMentionCountLimit == false
|
||||
|
||||
AutoNsfwMedia: other.IntoPointer(false),
|
||||
AutoCwPosts: other.IntoPointer(false),
|
||||
|
@ -112,7 +122,67 @@ var fullAdminRole = Role{
|
|||
CanSendAnnouncements: other.IntoPointer(true),
|
||||
}
|
||||
|
||||
// Role for totally freezing an account, blocking all activity from it
|
||||
var AccountFreezeRole = Role{
|
||||
Name: "accountFreeze",
|
||||
Priority: math.MaxUint - 1,
|
||||
IsUserRole: false,
|
||||
IsBuiltIn: true,
|
||||
|
||||
CanSendMedia: other.IntoPointer(false),
|
||||
CanSendCustomEmotes: other.IntoPointer(false),
|
||||
CanSendCustomReactions: other.IntoPointer(false),
|
||||
CanSendPublicNotes: other.IntoPointer(false),
|
||||
CanSendLocalNotes: other.IntoPointer(false),
|
||||
CanSendFollowerOnlyNotes: other.IntoPointer(false),
|
||||
CanSendPrivateNotes: other.IntoPointer(false),
|
||||
CanSendReplies: other.IntoPointer(false),
|
||||
CanQuote: other.IntoPointer(false),
|
||||
CanBoost: other.IntoPointer(false),
|
||||
CanIncludeLinks: other.IntoPointer(false),
|
||||
CanIncludeSurvey: other.IntoPointer(false),
|
||||
CanFederateBsky: other.IntoPointer(false),
|
||||
CanFederateFedi: other.IntoPointer(false),
|
||||
|
||||
CanChangeDisplayName: other.IntoPointer(false),
|
||||
|
||||
BlockedUsers: []string{},
|
||||
CanSubmitReports: other.IntoPointer(false),
|
||||
CanLogin: other.IntoPointer(false),
|
||||
|
||||
CanMentionOthers: other.IntoPointer(false),
|
||||
HasMentionCountLimit: other.IntoPointer(false),
|
||||
MentionLimit: other.IntoPointer(
|
||||
uint32(math.MaxUint32),
|
||||
), // Set this to max, even if not used due to *HasMentionCountLimit == false
|
||||
|
||||
AutoNsfwMedia: other.IntoPointer(true),
|
||||
AutoCwPosts: other.IntoPointer(false),
|
||||
AutoCwPostsText: other.IntoPointer("Account frozen"),
|
||||
WithholdNotesForManualApproval: other.IntoPointer(true),
|
||||
ScanCreatedPublicNotes: other.IntoPointer(false),
|
||||
ScanCreatedLocalNotes: other.IntoPointer(false),
|
||||
ScanCreatedFollowerOnlyNotes: other.IntoPointer(false),
|
||||
ScanCreatedPrivateNotes: other.IntoPointer(false),
|
||||
DisallowInteractionsWith: []string{},
|
||||
|
||||
FullAdmin: other.IntoPointer(false),
|
||||
CanAffectOtherAdmins: other.IntoPointer(false),
|
||||
CanDeleteNotes: other.IntoPointer(false),
|
||||
CanConfirmWithheldNotes: other.IntoPointer(false),
|
||||
CanAssignRoles: other.IntoPointer(false),
|
||||
CanSupressInteractionsBetweenUsers: other.IntoPointer(false),
|
||||
CanOverwriteDisplayNames: other.IntoPointer(false),
|
||||
CanManageCustomEmotes: other.IntoPointer(false),
|
||||
CanViewDeletedNotes: other.IntoPointer(false),
|
||||
CanRecoverDeletedNotes: other.IntoPointer(false),
|
||||
CanManageAvatarDecorations: other.IntoPointer(false),
|
||||
CanManageAds: other.IntoPointer(false),
|
||||
CanSendAnnouncements: other.IntoPointer(false),
|
||||
}
|
||||
|
||||
var allDefaultRoles = []*Role{
|
||||
&DefaultUserRole,
|
||||
&fullAdminRole,
|
||||
&FullAdminRole,
|
||||
&AccountFreezeRole,
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue