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
|
@ -4,6 +4,15 @@ package server
|
|||
|
||||
import "time"
|
||||
|
||||
var (
|
||||
_ = linstromNote{}
|
||||
_ = linstromOriginServer{}
|
||||
_ = linstromMediaMetadata{}
|
||||
_ = linstromAccount{}
|
||||
_ = linstromCustomAccountField{}
|
||||
_ = linstromRole{}
|
||||
)
|
||||
|
||||
type linstromNote struct {
|
||||
Id string `jsonapi:"primary,notes"`
|
||||
RawContent string `jsonapi:"attr,content"`
|
||||
|
@ -29,7 +38,7 @@ type linstromOriginServer struct {
|
|||
Id int `jsonapi:"primary,origins"`
|
||||
CreatedAt time.Time `jsonapi:"attr,created_at"`
|
||||
UpdatedAt *time.Time `jsonapi:"attr,updated_at,omitempty"`
|
||||
ServerType string `jsonapi:"attr,server_type"` // one of "Linstrom", ""
|
||||
ServerType string `jsonapi:"attr,server_type"` // one of "Linstrom", "Mastodon", "Plemora", "Misskey" or "Wafrn"
|
||||
Domain string `jsonapi:"attr,domain"`
|
||||
DisplayName string `jsonapi:"attr,display_name"`
|
||||
Icon *linstromMediaMetadata `jsonapi:"relation,icon"`
|
||||
|
@ -68,10 +77,11 @@ type linstromAccount struct {
|
|||
RestrictedFollow bool `jsonapi:"attr,restricted_follow"`
|
||||
IdentifiesAs []string `jsonapi:"attr,identifies_as"`
|
||||
Pronouns []string `jsonapi:"attr,pronouns"`
|
||||
Roles []string `jsonapi:"attr,roles"`
|
||||
}
|
||||
|
||||
type linstromCustomAccountField struct {
|
||||
Id uint
|
||||
Id uint `jsonapi:"primary,custom_account_fields"`
|
||||
CreatedAt time.Time `jsonapi:"attr,created_at"`
|
||||
UpdatedAt *time.Time `jsonapi:"attr,updated_at,omitempty"`
|
||||
Key string `jsonapi:"attr,key"`
|
||||
|
@ -79,3 +89,86 @@ type linstromCustomAccountField struct {
|
|||
Verified *bool `jsonapi:"attr,verified,omitempty"`
|
||||
BelongsToId string `jsonapi:"attr,belongs_to_id"`
|
||||
}
|
||||
|
||||
// Role is essentially just a carbon copy of storage/roles.go
|
||||
type linstromRole struct {
|
||||
Id uint `jsonapi:"primary,roles"`
|
||||
CreatedAt time.Time `jsonapi:"attr,created_at"`
|
||||
UpdatedAt *time.Time `jsonapi:"attr,updated_at,omitempty"`
|
||||
|
||||
// Name of the role
|
||||
Name string `jsonapi:"attr,name"`
|
||||
|
||||
// Priority of the role
|
||||
// Lower priority gets applied first and thus overwritten by higher priority ones
|
||||
// If two roles have the same priority, the order is undetermined and may be random
|
||||
// Default priority for new roles is 1 to always overwrite default user
|
||||
// And full admin has max priority possible
|
||||
Priority uint `jsonapi:"attr,priority"`
|
||||
// Whether this role is for a for a single user only (like custom, per user permissions in Discord)
|
||||
// If yes, Name will be the id of the user in question
|
||||
IsUserRole bool `jsonapi:"attr,is_user_role"`
|
||||
|
||||
// Whether this role is one built into Linstrom from the start or not
|
||||
// Note: Built-in roles can't be modified
|
||||
IsBuiltIn bool `jsonapi:"attr,is_builtin"`
|
||||
|
||||
// --- User permissions ---
|
||||
CanSendMedia *bool `jsonapi:"attr,can_send_media"`
|
||||
CanSendCustomEmotes *bool `jsonapi:"attr,can_send_custom_emotes"`
|
||||
CanSendCustomReactions *bool `jsonapi:"attr,can_send_custom_reactions"`
|
||||
CanSendPublicNotes *bool `jsonapi:"attr,can_send_public_notes"`
|
||||
CanSendLocalNotes *bool `jsonapi:"attr,can_send_local_notes"`
|
||||
CanSendFollowerOnlyNotes *bool `jsonapi:"attr,can_send_follower_only_notes"`
|
||||
CanSendPrivateNotes *bool `jsonapi:"attr,can_send_private_notes"`
|
||||
CanSendReplies *bool `jsonapi:"attr,can_send_replies"`
|
||||
CanQuote *bool `jsonapi:"attr,can_quote"`
|
||||
CanBoost *bool `jsonapi:"attr,can_boost"`
|
||||
CanIncludeLinks *bool `jsonapi:"attr,can_include_links"`
|
||||
CanIncludeSurvey *bool `jsonapi:"attr,can_include_survey"`
|
||||
|
||||
CanChangeDisplayName *bool `jsonapi:"attr,can_change_display_name"`
|
||||
|
||||
BlockedUsers []string `jsonapi:"attr,blocked_users"`
|
||||
CanSubmitReports *bool `jsonapi:"attr,can_submit_reports"`
|
||||
CanLogin *bool `jsonapi:"attr,can_login"`
|
||||
|
||||
CanMentionOthers *bool `jsonapi:"attr,can_mention_others"`
|
||||
HasMentionCountLimit *bool `jsonapi:"attr,has_mention_count_limit"`
|
||||
MentionLimit *uint32 `jsonapi:"attr,mention_count_limit"`
|
||||
|
||||
// CanViewBoosts *bool
|
||||
// CanViewQuotes *bool
|
||||
// CanViewMedia *bool
|
||||
// CanViewCustomEmotes *bool
|
||||
|
||||
// --- Automod ---
|
||||
AutoNsfwMedia *bool `jsonapi:"attr,auto_nsfw_media"`
|
||||
AutoCwPosts *bool `jsonapi:"attr,auto_cw_posts"`
|
||||
AutoCwPostsText *string `jsonapi:"attr,auto_cw_posts_text"`
|
||||
ScanCreatedPublicNotes *bool `jsonapi:"attr,scan_created_public_notes"`
|
||||
ScanCreatedLocalNotes *bool `jsonapi:"attr,scan_created_local_notes"`
|
||||
ScanCreatedFollowerOnlyNotes *bool `jsonapi:"attr,scan_created_follower_only_notes"`
|
||||
ScanCreatedPrivateNotes *bool `jsonapi:"attr,scan_created_private_notes"`
|
||||
DisallowInteractionsWith []string `jsonapi:"attr,disallow_interactions_with"`
|
||||
|
||||
WithholdNotesForManualApproval *bool `jsonapi:"attr,withhold_notes_for_manual_approval"`
|
||||
WithholdNotesBasedOnRegex *bool `jsonapi:"attr,withhold_notes_based_on_regex"`
|
||||
WithholdNotesRegexes []string `jsonapi:"attr,withhold_notes_regexes"`
|
||||
|
||||
// --- Admin perms ---
|
||||
// If set, counts as all permissions being set as given and all restrictions being disabled
|
||||
FullAdmin *bool `jsonapi:"attr,full_admin"`
|
||||
CanAffectOtherAdmins *bool `jsonapi:"attr,can_affect_other_admins"`
|
||||
CanDeleteNotes *bool `jsonapi:"attr,can_delete_notes"`
|
||||
CanConfirmWithheldNotes *bool `jsonapi:"attr,can_confirm_withheld_notes"`
|
||||
CanAssignRoles *bool `jsonapi:"attr,can_assign_roles"`
|
||||
CanSupressInteractionsBetweenUsers *bool `jsonapi:"attr,can_supress_interactions_between_users"`
|
||||
CanOverwriteDisplayNames *bool `jsonapi:"attr,can_overwrite_display_names"`
|
||||
CanManageCustomEmotes *bool `jsonapi:"attr,can_manage_custom_emotes"`
|
||||
CanViewDeletedNotes *bool `jsonapi:"attr,can_view_deleted_notes"`
|
||||
CanRecoverDeletedNotes *bool `jsonapi:"attr,can_recover_deleted_notes"`
|
||||
CanManageAvatarDecorations *bool `jsonapi:"attr,can_manage_avatar_decorations"`
|
||||
CanManageAds *bool `jsonapi:"attr,can_manage_ads"`
|
||||
CanSendAnnouncements *bool `jsonapi:"attr,can_send_announcements"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue