linstrom/server/apiLinstromTypes.go

175 lines
9.1 KiB
Go
Raw Normal View History

package server
// Contains types used by the Linstrom API. Types comply with the jsonapi spec
import "time"
var (
_ = linstromNote{}
_ = linstromOriginServer{}
_ = linstromMediaMetadata{}
_ = linstromAccount{}
_ = linstromCustomAccountField{}
_ = linstromRole{}
)
type linstromNote struct {
Id string `jsonapi:"primary,notes"`
RawContent string `jsonapi:"attr,content"`
OriginServer *linstromOriginServer `jsonapi:"relation,origin_server"`
OriginServerId int `jsonapi:"attr,origin_server_id"`
ReactionCount string `jsonapi:"attr,reaction_count"`
CreatedAt time.Time `jsonapi:"attr,created_at"`
UpdatedAt *time.Time `jsonapi:"attr,updated_at,omitempty"`
Author *linstromAccount `jsonapi:"relation,author"`
AuthorId string `jsonapi:"attr,author_id"`
ContentWarning *string `jsonapi:"attr,content_warning,omitempty"`
InReplyToId *string `jsonapi:"attr,in_reply_to_id,omitempty"`
QuotesId *string `jsonapi:"attr,quotes_id,omitempty"`
EmoteIds []string `jsonapi:"attr,emotes,omitempty"`
Attachments []*linstromMediaMetadata `jsonapi:"relation,attachments,omitempty"`
AttachmentIds []string `jsonapi:"attr,attachment_ids"`
AccessLevel uint8 `jsonapi:"attr,access_level"`
Pings []*linstromAccount `jsonapi:"relation,pings,omitempty"`
PingIds []string `jsonapi:"attr,ping_ids,omitempty"`
}
type linstromOriginServer struct {
Id uint `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", "Mastodon", "Plemora", "Misskey" or "Wafrn"
Domain string `jsonapi:"attr,domain"`
DisplayName string `jsonapi:"attr,display_name"`
Icon *linstromMediaMetadata `jsonapi:"relation,icon"`
IsSelf bool `jsonapi:"attr,is_self"`
}
type linstromMediaMetadata struct {
Id string `jsonapi:"primary,medias"`
CreatedAt time.Time `jsonapi:"attr,created_at"`
UpdatedAt *time.Time `jsonapi:"attr,updated_at,omitempty"`
IsRemote bool `jsonapi:"attr,is_remote"`
Url string `jsonapi:"attr,url"`
MimeType string `jsonapi:"attr,mime_type"`
Name string `jsonapi:"attr,name"`
AltText string `jsonapi:"attr,alt_text"`
Blurred bool `jsonapi:"attr,blurred"`
}
type linstromAccount struct {
Id string `jsonapi:"primary,accounts"`
CreatedAt time.Time `jsonapi:"attr,created_at"`
UpdatedAt *time.Time `jsonapi:"attr,updated_at,omitempty"`
Username string `jsonapi:"attr,username"`
OriginServer *linstromOriginServer `jsonapi:"relation,origin_server"`
OriginServerId int `jsonapi:"attr,origin_server_id"`
DisplayName string `jsonapi:"attr,display_name"`
CustomFields []*linstromCustomAccountField `jsonapi:"relation,custom_fields"`
CustomFieldIds []uint `jsonapi:"attr,custom_field_ids"`
IsBot bool `jsonapi:"attr,is_bot"`
Description string `jsonapi:"attr,description"`
Icon *linstromMediaMetadata `jsonapi:"relation,icon"`
Banner *linstromMediaMetadata `jsonapi:"relation,banner"`
FollowerIds []string `jsonapi:"attr,follows_ids"`
FollowingIds []string `jsonapi:"attr,following_ids"`
Indexable bool `jsonapi:"attr,indexable"`
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 `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"`
Value string `jsonapi:"attr,value"`
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"`
}