From a94a360773e8ce48c21f5586b2bc9e7349c14de6 Mon Sep 17 00:00:00 2001 From: mStar Date: Wed, 20 Nov 2024 16:11:11 +0100 Subject: [PATCH] Fix-ish frontend models, a generator and a generate command --- cmd/RolesFrontendGenerator/main.go | 9 +- frontend-reactive/app/models/account.ts | 12 +- .../app/models/custom-account-field.ts | 8 +- frontend-reactive/app/models/emote.ts | 12 +- .../app/models/media-metadata.ts | 8 +- frontend-reactive/app/models/note.ts | 12 +- .../{remote-server.ts => origin-server.ts} | 8 +- frontend-reactive/app/models/reaction.ts | 8 +- frontend-reactive/app/models/relation.ts | 8 +- frontend-reactive/app/models/role.ts | 84 ++-- server/apiLinstromTypeHelpers_generated.go | 2 +- server/apiLinstromTypes_generated.go | 76 +-- storage/roles.go | 7 + storage/rolesUtil_generated.go | 440 +++++++++--------- 14 files changed, 380 insertions(+), 314 deletions(-) rename frontend-reactive/app/models/{remote-server.ts => origin-server.ts} (50%) diff --git a/cmd/RolesFrontendGenerator/main.go b/cmd/RolesFrontendGenerator/main.go index 83138b6..2a0cbe1 100644 --- a/cmd/RolesFrontendGenerator/main.go +++ b/cmd/RolesFrontendGenerator/main.go @@ -91,7 +91,7 @@ func main() { `) outBuilder.WriteString("import Model, { attr } from '@ember-data/model';\n\n") - outBuilder.WriteString("export default class RoleModel extends Model {\n") + outBuilder.WriteString("export default class Role extends Model {\n") outBuilder.WriteString(` @attr() declare createdAt: Date @attr() declare updatedAt: Date @attr() declare name: string @@ -105,7 +105,12 @@ func main() { outBuilder.WriteString(fNT(n, t)) } - outBuilder.WriteString("}") + outBuilder.WriteString("}\n\n") + outBuilder.WriteString(`declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + role: Role + } +}`) fmt.Fprint(output, outBuilder.String()) } diff --git a/frontend-reactive/app/models/account.ts b/frontend-reactive/app/models/account.ts index 5caee9d..9057f97 100644 --- a/frontend-reactive/app/models/account.ts +++ b/frontend-reactive/app/models/account.ts @@ -1,13 +1,13 @@ import Model, { attr, hasMany, type AsyncHasMany } from '@ember-data/model' -import type RemoteServerModel from './remote-server' import type CustomAccountFieldModel from './custom-account-field' import type MediaMetadataModel from './media-metadata' +import type OriginServer from './origin-server' -export default class AccountModel extends Model { +export default class Account extends Model { @attr declare createdAt: Date @attr declare updatedAt: Date @attr declare username: string - @attr declare originServer: RemoteServerModel + @attr declare originServer: OriginServer @attr declare originServerId: number @attr declare displayName: string @hasMany('custom-account-field') @@ -28,3 +28,9 @@ export default class AccountModel extends Model { @attr declare pronouns: Array @attr declare roles: Array } + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + account: Account + } +} diff --git a/frontend-reactive/app/models/custom-account-field.ts b/frontend-reactive/app/models/custom-account-field.ts index db00952..73b7093 100644 --- a/frontend-reactive/app/models/custom-account-field.ts +++ b/frontend-reactive/app/models/custom-account-field.ts @@ -1,6 +1,6 @@ import Model, { attr } from '@ember-data/model' -export default class CustomAccountFieldModel extends Model { +export default class CustomAccountField extends Model { @attr declare createdAt: Date @attr declare updatedAt: Date @attr declare key: string @@ -8,3 +8,9 @@ export default class CustomAccountFieldModel extends Model { @attr declare verified?: boolean @attr declare belongsToId: string } + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + customAccountField: CustomAccountField + } +} diff --git a/frontend-reactive/app/models/emote.ts b/frontend-reactive/app/models/emote.ts index a483915..abea37b 100644 --- a/frontend-reactive/app/models/emote.ts +++ b/frontend-reactive/app/models/emote.ts @@ -1,11 +1,17 @@ import Model, { attr } from '@ember-data/model' import type MediaMetadataModel from './media-metadata' -import type RemoteServerModel from './remote-server' +import type OriginServer from './origin-server' -export default class EmoteModel extends Model { +export default class Emote extends Model { @attr declare metadataId: string @attr declare metadata: MediaMetadataModel @attr declare name: string @attr declare serverId: number - @attr declare server: RemoteServerModel + @attr declare server: OriginServer +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + emote: Emote + } } diff --git a/frontend-reactive/app/models/media-metadata.ts b/frontend-reactive/app/models/media-metadata.ts index 2f2986e..7eea37b 100644 --- a/frontend-reactive/app/models/media-metadata.ts +++ b/frontend-reactive/app/models/media-metadata.ts @@ -1,6 +1,6 @@ import Model, { attr } from '@ember-data/model' -export default class MediaMetadataModel extends Model { +export default class MediaMetadata extends Model { @attr declare createdAt: Date @attr declare updatedAt: Date @attr declare isRemote: boolean @@ -10,3 +10,9 @@ export default class MediaMetadataModel extends Model { @attr declare altText: string @attr declare blurred: boolean } + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + mediaMetadata: MediaMetadata + } +} diff --git a/frontend-reactive/app/models/note.ts b/frontend-reactive/app/models/note.ts index cabc14b..aad185c 100644 --- a/frontend-reactive/app/models/note.ts +++ b/frontend-reactive/app/models/note.ts @@ -1,11 +1,11 @@ import Model, { attr, hasMany, type AsyncHasMany } from '@ember-data/model' -import type RemoteServerModel from './remote-server' import type AccountModel from './account' import type MediaMetadataModel from './media-metadata' +import type OriginServer from './origin-server' -export default class NoteModel extends Model { +export default class Note extends Model { @attr declare content: string - @attr declare originServer: RemoteServerModel + @attr declare originServer: OriginServer @attr declare originServerId: number @attr declare reactionCount: number @attr declare createdAt: Date @@ -24,3 +24,9 @@ export default class NoteModel extends Model { @attr declare pingIds?: Array @attr declare reactionIds: Array } + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + note: Note + } +} diff --git a/frontend-reactive/app/models/remote-server.ts b/frontend-reactive/app/models/origin-server.ts similarity index 50% rename from frontend-reactive/app/models/remote-server.ts rename to frontend-reactive/app/models/origin-server.ts index 2cbe8e7..58928a9 100644 --- a/frontend-reactive/app/models/remote-server.ts +++ b/frontend-reactive/app/models/origin-server.ts @@ -1,8 +1,14 @@ import Model, { attr } from '@ember-data/model' -export default class RemoteServerModel extends Model { +export default class OriginServer extends Model { @attr() declare serverType: string @attr() declare name: string @attr() declare iconUrl: string @attr() declare isSelf: boolean } + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + originServer: OriginServer + } +} diff --git a/frontend-reactive/app/models/reaction.ts b/frontend-reactive/app/models/reaction.ts index d201b91..5a608f8 100644 --- a/frontend-reactive/app/models/reaction.ts +++ b/frontend-reactive/app/models/reaction.ts @@ -1,9 +1,15 @@ import Model, { attr } from '@ember-data/model' import type EmoteModel from './emote' -export default class ReactionModel extends Model { +export default class Reaction extends Model { @attr declare noteId: string @attr declare reactorId: string @attr declare emoteId: number @attr declare emote: EmoteModel } + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + reaction: Reaction + } +} diff --git a/frontend-reactive/app/models/relation.ts b/frontend-reactive/app/models/relation.ts index f5be28b..c5b20f7 100644 --- a/frontend-reactive/app/models/relation.ts +++ b/frontend-reactive/app/models/relation.ts @@ -1,6 +1,6 @@ import Model, { attr } from '@ember-data/model' -export default class RelationModel extends Model { +export default class Relation extends Model { @attr declare createdAt: Date @attr declare updatedAt: Date @attr declare fromId: string @@ -8,3 +8,9 @@ export default class RelationModel extends Model { @attr declare requested: boolean @attr declare accepted: boolean } + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + relation: Relation + } +} diff --git a/frontend-reactive/app/models/role.ts b/frontend-reactive/app/models/role.ts index 5ff3e0b..d4484fa 100644 --- a/frontend-reactive/app/models/role.ts +++ b/frontend-reactive/app/models/role.ts @@ -2,7 +2,7 @@ // If you need to refresh the content, run go generate again import Model, { attr } from '@ember-data/model'; -export default class RoleModel extends Model { +export default class Role extends Model { @attr() declare createdAt: Date @attr() declare updatedAt: Date @attr() declare name: string @@ -10,49 +10,55 @@ export default class RoleModel extends Model { @attr() declare isUserRole: boolean @attr() declare isBuiltIn: boolean - @attr() declare canSendMedia?: boolean - @attr() declare canSendFollowerOnlyNotes?: boolean - @attr() declare canIncludeLinks?: boolean - @attr() declare hasMentionCountLimit?: boolean - @attr() declare scanCreatedFollowerOnlyNotes?: boolean - @attr() declare canAffectOtherAdmins?: boolean - @attr() declare canConfirmWithheldNotes?: boolean - @attr() declare canSendCustomEmotes?: boolean - @attr() declare scanCreatedLocalNotes?: boolean - @attr() declare canOverwriteDisplayNames?: boolean - @attr() declare canRecoverDeletedNotes?: boolean - @attr() declare canManageAds?: boolean - @attr() declare canFederateBsky?: boolean - @attr() declare autoCwPostsText?: string - @attr() declare scanCreatedPublicNotes?: boolean - @attr() declare withholdNotesForManualApproval?: boolean - @attr() declare canSendReplies?: boolean - @attr() declare autoNsfwMedia?: boolean @attr() declare canSendCustomReactions?: boolean - @attr() declare canSendLocalNotes?: boolean - @attr() declare canSendPrivateNotes?: boolean - @attr() declare canFederateFedi?: boolean - @attr() declare withholdNotesBasedOnRegex?: boolean - @attr() declare fullAdmin?: boolean - @attr() declare canSendAnnouncements?: boolean - @attr() declare canQuote?: boolean - @attr() declare canIncludeSurvey?: boolean - @attr() declare canChangeDisplayName?: boolean - @attr() declare blockedUsers?: Array - @attr() declare canMentionOthers?: boolean - @attr() declare autoCwPosts?: boolean - @attr() declare canSendPublicNotes?: boolean - @attr() declare mentionLimit?: number - @attr() declare scanCreatedPrivateNotes?: boolean + @attr() declare autoCwPostsText?: string @attr() declare withholdNotesRegexes?: Array @attr() declare canAssignRoles?: boolean @attr() declare canSupressInteractionsBetweenUsers?: boolean + @attr() declare canSendCustomEmotes?: boolean + @attr() declare canOverwriteDisplayNames?: boolean @attr() declare canManageCustomEmotes?: boolean - @attr() declare canViewDeletedNotes?: boolean - @attr() declare canBoost?: boolean - @attr() declare canSubmitReports?: boolean - @attr() declare canLogin?: boolean - @attr() declare disallowInteractionsWith?: Array @attr() declare canDeleteNotes?: boolean @attr() declare canManageAvatarDecorations?: boolean + @attr() declare canManageAds?: boolean + @attr() declare blockedUsers?: Array + @attr() declare hasMentionCountLimit?: boolean + @attr() declare disallowInteractionsWith?: Array + @attr() declare withholdNotesBasedOnRegex?: boolean + @attr() declare fullAdmin?: boolean + @attr() declare canSendAnnouncements?: boolean + @attr() declare autoNsfwMedia?: boolean + @attr() declare scanCreatedPublicNotes?: boolean + @attr() declare scanCreatedPrivateNotes?: boolean + @attr() declare canSendFollowerOnlyNotes?: boolean + @attr() declare canSendPrivateNotes?: boolean + @attr() declare canIncludeSurvey?: boolean + @attr() declare canChangeDisplayName?: boolean + @attr() declare canLogin?: boolean + @attr() declare canAffectOtherAdmins?: boolean + @attr() declare autoCwPosts?: boolean + @attr() declare scanCreatedFollowerOnlyNotes?: boolean + @attr() declare canViewDeletedNotes?: boolean + @attr() declare mentionLimit?: number + @attr() declare withholdNotesForManualApproval?: boolean + @attr() declare canConfirmWithheldNotes?: boolean + @attr() declare canSendMedia?: boolean + @attr() declare canSendPublicNotes?: boolean + @attr() declare canSendReplies?: boolean + @attr() declare canQuote?: boolean + @attr() declare canIncludeLinks?: boolean + @attr() declare canRecoverDeletedNotes?: boolean + @attr() declare canMentionOthers?: boolean + @attr() declare scanCreatedLocalNotes?: boolean + @attr() declare canSendLocalNotes?: boolean + @attr() declare canBoost?: boolean + @attr() declare canFederateFedi?: boolean + @attr() declare canFederateBsky?: boolean + @attr() declare canSubmitReports?: boolean +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + role: Role + } } \ No newline at end of file diff --git a/server/apiLinstromTypeHelpers_generated.go b/server/apiLinstromTypeHelpers_generated.go index 468ffef..f78672c 100644 --- a/server/apiLinstromTypeHelpers_generated.go +++ b/server/apiLinstromTypeHelpers_generated.go @@ -4,5 +4,5 @@ package server import "gitlab.com/mstarongitlab/linstrom/storage" func convertRoleStorageToLinstrom(r storage.Role) linstromRole { -return linstromRole{Id:r.ID,CreatedAt:r.CreatedAt,UpdatedAt:r.UpdatedAt,Name:r.Name,Priority:r.Priority,IsUserRole:r.IsUserRole,IsBuiltIn:r.IsBuiltIn,CanSendAnnouncements:r.CanSendAnnouncements,CanIncludeSurvey:r.CanIncludeSurvey,CanSubmitReports:r.CanSubmitReports,CanMentionOthers:r.CanMentionOthers,WithholdNotesBasedOnRegex:r.WithholdNotesBasedOnRegex,CanSendMedia:r.CanSendMedia,CanSendLocalNotes:r.CanSendLocalNotes,ScanCreatedFollowerOnlyNotes:r.ScanCreatedFollowerOnlyNotes,CanOverwriteDisplayNames:r.CanOverwriteDisplayNames,CanDeleteNotes:r.CanDeleteNotes,CanSupressInteractionsBetweenUsers:r.CanSupressInteractionsBetweenUsers,CanManageAds:r.CanManageAds,BlockedUsers:r.BlockedUsers,CanLogin:r.CanLogin,AutoCwPosts:r.AutoCwPosts,WithholdNotesRegexes:r.WithholdNotesRegexes,ScanCreatedPublicNotes:r.ScanCreatedPublicNotes,ScanCreatedLocalNotes:r.ScanCreatedLocalNotes,CanAffectOtherAdmins:r.CanAffectOtherAdmins,CanAssignRoles:r.CanAssignRoles,CanSendFollowerOnlyNotes:r.CanSendFollowerOnlyNotes,CanBoost:r.CanBoost,CanFederateBsky:r.CanFederateBsky,HasMentionCountLimit:r.HasMentionCountLimit,DisallowInteractionsWith:r.DisallowInteractionsWith,CanViewDeletedNotes:r.CanViewDeletedNotes,CanSendCustomReactions:r.CanSendCustomReactions,CanSendReplies:r.CanSendReplies,CanIncludeLinks:r.CanIncludeLinks,CanChangeDisplayName:r.CanChangeDisplayName,CanSendPrivateNotes:r.CanSendPrivateNotes,MentionLimit:r.MentionLimit,WithholdNotesForManualApproval:r.WithholdNotesForManualApproval,CanRecoverDeletedNotes:r.CanRecoverDeletedNotes,AutoCwPostsText:r.AutoCwPostsText,ScanCreatedPrivateNotes:r.ScanCreatedPrivateNotes,CanSendCustomEmotes:r.CanSendCustomEmotes,CanSendPublicNotes:r.CanSendPublicNotes,CanQuote:r.CanQuote,CanFederateFedi:r.CanFederateFedi,CanManageAvatarDecorations:r.CanManageAvatarDecorations,AutoNsfwMedia:r.AutoNsfwMedia,FullAdmin:r.FullAdmin,CanConfirmWithheldNotes:r.CanConfirmWithheldNotes,CanManageCustomEmotes:r.CanManageCustomEmotes,} +return linstromRole{Id:r.ID,CreatedAt:r.CreatedAt,UpdatedAt:r.UpdatedAt,Name:r.Name,Priority:r.Priority,IsUserRole:r.IsUserRole,IsBuiltIn:r.IsBuiltIn,CanRecoverDeletedNotes:r.CanRecoverDeletedNotes,CanSendFollowerOnlyNotes:r.CanSendFollowerOnlyNotes,CanSendReplies:r.CanSendReplies,AutoNsfwMedia:r.AutoNsfwMedia,WithholdNotesForManualApproval:r.WithholdNotesForManualApproval,CanAffectOtherAdmins:r.CanAffectOtherAdmins,CanAssignRoles:r.CanAssignRoles,CanOverwriteDisplayNames:r.CanOverwriteDisplayNames,CanManageAvatarDecorations:r.CanManageAvatarDecorations,CanSendMedia:r.CanSendMedia,ScanCreatedLocalNotes:r.ScanCreatedLocalNotes,CanSendCustomEmotes:r.CanSendCustomEmotes,CanSendPublicNotes:r.CanSendPublicNotes,CanIncludeSurvey:r.CanIncludeSurvey,AutoCwPostsText:r.AutoCwPostsText,CanManageCustomEmotes:r.CanManageCustomEmotes,CanSendAnnouncements:r.CanSendAnnouncements,CanSendLocalNotes:r.CanSendLocalNotes,CanBoost:r.CanBoost,CanLogin:r.CanLogin,CanMentionOthers:r.CanMentionOthers,CanManageAds:r.CanManageAds,CanQuote:r.CanQuote,CanChangeDisplayName:r.CanChangeDisplayName,CanSubmitReports:r.CanSubmitReports,FullAdmin:r.FullAdmin,CanSendPrivateNotes:r.CanSendPrivateNotes,CanIncludeLinks:r.CanIncludeLinks,CanFederateFedi:r.CanFederateFedi,HasMentionCountLimit:r.HasMentionCountLimit,AutoCwPosts:r.AutoCwPosts,ScanCreatedPublicNotes:r.ScanCreatedPublicNotes,DisallowInteractionsWith:r.DisallowInteractionsWith,CanDeleteNotes:r.CanDeleteNotes,CanConfirmWithheldNotes:r.CanConfirmWithheldNotes,ScanCreatedPrivateNotes:r.ScanCreatedPrivateNotes,WithholdNotesBasedOnRegex:r.WithholdNotesBasedOnRegex,WithholdNotesRegexes:r.WithholdNotesRegexes,CanSupressInteractionsBetweenUsers:r.CanSupressInteractionsBetweenUsers,CanViewDeletedNotes:r.CanViewDeletedNotes,CanSendCustomReactions:r.CanSendCustomReactions,CanFederateBsky:r.CanFederateBsky,BlockedUsers:r.BlockedUsers,MentionLimit:r.MentionLimit,ScanCreatedFollowerOnlyNotes:r.ScanCreatedFollowerOnlyNotes,} } diff --git a/server/apiLinstromTypes_generated.go b/server/apiLinstromTypes_generated.go index fe99fec..53e6034 100644 --- a/server/apiLinstromTypes_generated.go +++ b/server/apiLinstromTypes_generated.go @@ -11,49 +11,49 @@ type linstromRole struct { Priority uint32 `jsonapi:"attr,priority"` IsUserRole bool `jsonapi:"attr,is-user-role"` IsBuiltIn bool `jsonapi:"attr,is-built-in"` - CanQuote *bool `jsonapi:"attr,can-quote"` - CanFederateFedi *bool `jsonapi:"attr,can-federate-fedi"` - DisallowInteractionsWith []string `jsonapi:"attr,disallow-interactions-with"` - WithholdNotesRegexes []string `jsonapi:"attr,withhold-notes-regexes"` - FullAdmin *bool `jsonapi:"attr,full-admin"` - CanViewDeletedNotes *bool `jsonapi:"attr,can-view-deleted-notes"` - CanSendCustomReactions *bool `jsonapi:"attr,can-send-custom-reactions"` - CanSendFollowerOnlyNotes *bool `jsonapi:"attr,can-send-follower-only-notes"` - CanLogin *bool `jsonapi:"attr,can-login"` - AutoCwPostsText *string `jsonapi:"attr,auto-cw-posts-text"` - WithholdNotesForManualApproval *bool `jsonapi:"attr,withhold-notes-for-manual-approval"` - CanDeleteNotes *bool `jsonapi:"attr,can-delete-notes"` - CanSendLocalNotes *bool `jsonapi:"attr,can-send-local-notes"` CanIncludeLinks *bool `jsonapi:"attr,can-include-links"` - AutoCwPosts *bool `jsonapi:"attr,auto-cw-posts"` - WithholdNotesBasedOnRegex *bool `jsonapi:"attr,withhold-notes-based-on-regex"` - CanAffectOtherAdmins *bool `jsonapi:"attr,can-affect-other-admins"` - CanAssignRoles *bool `jsonapi:"attr,can-assign-roles"` - CanSendMedia *bool `jsonapi:"attr,can-send-media"` - BlockedUsers []string `jsonapi:"attr,blocked-users"` - AutoNsfwMedia *bool `jsonapi:"attr,auto-nsfw-media"` - CanConfirmWithheldNotes *bool `jsonapi:"attr,can-confirm-withheld-notes"` - CanOverwriteDisplayNames *bool `jsonapi:"attr,can-overwrite-display-names"` - CanManageAds *bool `jsonapi:"attr,can-manage-ads"` CanIncludeSurvey *bool `jsonapi:"attr,can-include-survey"` - CanSubmitReports *bool `jsonapi:"attr,can-submit-reports"` - ScanCreatedFollowerOnlyNotes *bool `jsonapi:"attr,scan-created-follower-only-notes"` + CanLogin *bool `jsonapi:"attr,can-login"` + CanSupressInteractionsBetweenUsers *bool `jsonapi:"attr,can-supress-interactions-between-users"` CanManageCustomEmotes *bool `jsonapi:"attr,can-manage-custom-emotes"` - CanManageAvatarDecorations *bool `jsonapi:"attr,can-manage-avatar-decorations"` CanSendAnnouncements *bool `jsonapi:"attr,can-send-announcements"` - CanBoost *bool `jsonapi:"attr,can-boost"` - ScanCreatedPublicNotes *bool `jsonapi:"attr,scan-created-public-notes"` + CanSendReplies *bool `jsonapi:"attr,can-send-replies"` + CanRecoverDeletedNotes *bool `jsonapi:"attr,can-recover-deleted-notes"` + CanMentionOthers *bool `jsonapi:"attr,can-mention-others"` + CanSendFollowerOnlyNotes *bool `jsonapi:"attr,can-send-follower-only-notes"` + CanSendPrivateNotes *bool `jsonapi:"attr,can-send-private-notes"` HasMentionCountLimit *bool `jsonapi:"attr,has-mention-count-limit"` MentionLimit *uint32 `jsonapi:"attr,mention-limit"` - CanSendCustomEmotes *bool `jsonapi:"attr,can-send-custom-emotes"` - CanChangeDisplayName *bool `jsonapi:"attr,can-change-display-name"` - ScanCreatedLocalNotes *bool `jsonapi:"attr,scan-created-local-notes"` - CanSupressInteractionsBetweenUsers *bool `jsonapi:"attr,can-supress-interactions-between-users"` - CanSendReplies *bool `jsonapi:"attr,can-send-replies"` - CanFederateBsky *bool `jsonapi:"attr,can-federate-bsky"` - CanMentionOthers *bool `jsonapi:"attr,can-mention-others"` - ScanCreatedPrivateNotes *bool `jsonapi:"attr,scan-created-private-notes"` - CanRecoverDeletedNotes *bool `jsonapi:"attr,can-recover-deleted-notes"` + ScanCreatedFollowerOnlyNotes *bool `jsonapi:"attr,scan-created-follower-only-notes"` + FullAdmin *bool `jsonapi:"attr,full-admin"` CanSendPublicNotes *bool `jsonapi:"attr,can-send-public-notes"` - CanSendPrivateNotes *bool `jsonapi:"attr,can-send-private-notes"` + CanFederateBsky *bool `jsonapi:"attr,can-federate-bsky"` + CanSubmitReports *bool `jsonapi:"attr,can-submit-reports"` + AutoNsfwMedia *bool `jsonapi:"attr,auto-nsfw-media"` + AutoCwPostsText *string `jsonapi:"attr,auto-cw-posts-text"` + WithholdNotesForManualApproval *bool `jsonapi:"attr,withhold-notes-for-manual-approval"` + CanManageAds *bool `jsonapi:"attr,can-manage-ads"` + CanFederateFedi *bool `jsonapi:"attr,can-federate-fedi"` + CanChangeDisplayName *bool `jsonapi:"attr,can-change-display-name"` + ScanCreatedPublicNotes *bool `jsonapi:"attr,scan-created-public-notes"` + ScanCreatedPrivateNotes *bool `jsonapi:"attr,scan-created-private-notes"` + CanAssignRoles *bool `jsonapi:"attr,can-assign-roles"` + CanSendCustomReactions *bool `jsonapi:"attr,can-send-custom-reactions"` + BlockedUsers []string `jsonapi:"attr,blocked-users"` + DisallowInteractionsWith []string `jsonapi:"attr,disallow-interactions-with"` + CanDeleteNotes *bool `jsonapi:"attr,can-delete-notes"` + CanViewDeletedNotes *bool `jsonapi:"attr,can-view-deleted-notes"` + CanManageAvatarDecorations *bool `jsonapi:"attr,can-manage-avatar-decorations"` + CanSendMedia *bool `jsonapi:"attr,can-send-media"` + CanSendLocalNotes *bool `jsonapi:"attr,can-send-local-notes"` + CanBoost *bool `jsonapi:"attr,can-boost"` + AutoCwPosts *bool `jsonapi:"attr,auto-cw-posts"` + ScanCreatedLocalNotes *bool `jsonapi:"attr,scan-created-local-notes"` + WithholdNotesRegexes []string `jsonapi:"attr,withhold-notes-regexes"` + CanSendCustomEmotes *bool `jsonapi:"attr,can-send-custom-emotes"` + WithholdNotesBasedOnRegex *bool `jsonapi:"attr,withhold-notes-based-on-regex"` + CanAffectOtherAdmins *bool `jsonapi:"attr,can-affect-other-admins"` + CanConfirmWithheldNotes *bool `jsonapi:"attr,can-confirm-withheld-notes"` + CanOverwriteDisplayNames *bool `jsonapi:"attr,can-overwrite-display-names"` + CanQuote *bool `jsonapi:"attr,can-quote"` } \ No newline at end of file diff --git a/storage/roles.go b/storage/roles.go index f9ea761..2bb6840 100644 --- a/storage/roles.go +++ b/storage/roles.go @@ -7,6 +7,12 @@ import ( "gorm.io/gorm" ) +// Could I collapse all these go:generate command into more condensed ones? +// Yes +// Will I do that? +// No +// This is explicit in what is being done. And easier to understand + //go:generate go build -o RolesGenerator ../cmd/RolesGenerator/main.go //go:generate ./RolesGenerator -input=roles.go -output=rolesUtil_generated.go //go:generate rm RolesGenerator @@ -21,6 +27,7 @@ import ( //go:generate go build -o FrontendGenerator ../cmd/RolesFrontendGenerator/main.go //go:generate ./FrontendGenerator -input=roles.go -output=../frontend-reactive/app/models/role.ts +//go:generate rm FrontendGenerator // A role is, in concept, similar to how Discord handles roles // Some permission can be either disallowed (&false), don't care (nil) or allowed (&true) diff --git a/storage/rolesUtil_generated.go b/storage/rolesUtil_generated.go index 2343821..3ee693a 100644 --- a/storage/rolesUtil_generated.go +++ b/storage/rolesUtil_generated.go @@ -11,26 +11,77 @@ func CollapseRolesIntoOne(roles ...Role) Role { startingRole := RoleDeepCopy(DefaultUserRole) slices.SortFunc(roles, func(a, b Role) int { return int(int64(a.Priority)-int64(b.Priority)) }) for _, role := range roles { + if role.CanSendReplies != nil { + *startingRole.CanSendReplies = *role.CanSendReplies + } + if role.CanBoost != nil { + *startingRole.CanBoost = *role.CanBoost + } + if role.AutoNsfwMedia != nil { + *startingRole.AutoNsfwMedia = *role.AutoNsfwMedia + } if role.WithholdNotesForManualApproval != nil { *startingRole.WithholdNotesForManualApproval = *role.WithholdNotesForManualApproval } - if role.CanIncludeLinks != nil { - *startingRole.CanIncludeLinks = *role.CanIncludeLinks + if role.WithholdNotesBasedOnRegex != nil { + *startingRole.WithholdNotesBasedOnRegex = *role.WithholdNotesBasedOnRegex } - if role.BlockedUsers != nil { - startingRole.BlockedUsers = append(startingRole.BlockedUsers, role.BlockedUsers...) + if role.CanSendCustomReactions != nil { + *startingRole.CanSendCustomReactions = *role.CanSendCustomReactions } - if role.HasMentionCountLimit != nil { - *startingRole.HasMentionCountLimit = *role.HasMentionCountLimit + if role.CanSendLocalNotes != nil { + *startingRole.CanSendLocalNotes = *role.CanSendLocalNotes } - if role.MentionLimit != nil { - *startingRole.MentionLimit = *role.MentionLimit + if role.DisallowInteractionsWith != nil { + startingRole.DisallowInteractionsWith = append(startingRole.DisallowInteractionsWith, role.DisallowInteractionsWith...) + } + if role.CanDeleteNotes != nil { + *startingRole.CanDeleteNotes = *role.CanDeleteNotes + } + if role.CanSupressInteractionsBetweenUsers != nil { + *startingRole.CanSupressInteractionsBetweenUsers = *role.CanSupressInteractionsBetweenUsers + } + if role.CanSendPublicNotes != nil { + *startingRole.CanSendPublicNotes = *role.CanSendPublicNotes + } + if role.ScanCreatedPrivateNotes != nil { + *startingRole.ScanCreatedPrivateNotes = *role.ScanCreatedPrivateNotes } if role.ScanCreatedPublicNotes != nil { *startingRole.ScanCreatedPublicNotes = *role.ScanCreatedPublicNotes } - if role.AutoNsfwMedia != nil { - *startingRole.AutoNsfwMedia = *role.AutoNsfwMedia + if role.CanConfirmWithheldNotes != nil { + *startingRole.CanConfirmWithheldNotes = *role.CanConfirmWithheldNotes + } + if role.CanManageAds != nil { + *startingRole.CanManageAds = *role.CanManageAds + } + if role.CanIncludeSurvey != nil { + *startingRole.CanIncludeSurvey = *role.CanIncludeSurvey + } + if role.CanLogin != nil { + *startingRole.CanLogin = *role.CanLogin + } + if role.CanChangeDisplayName != nil { + *startingRole.CanChangeDisplayName = *role.CanChangeDisplayName + } + if role.FullAdmin != nil { + *startingRole.FullAdmin = *role.FullAdmin + } + if role.CanOverwriteDisplayNames != nil { + *startingRole.CanOverwriteDisplayNames = *role.CanOverwriteDisplayNames + } + if role.CanSendCustomEmotes != nil { + *startingRole.CanSendCustomEmotes = *role.CanSendCustomEmotes + } + if role.CanQuote != nil { + *startingRole.CanQuote = *role.CanQuote + } + if role.CanSubmitReports != nil { + *startingRole.CanSubmitReports = *role.CanSubmitReports + } + if role.WithholdNotesRegexes != nil { + startingRole.WithholdNotesRegexes = append(startingRole.WithholdNotesRegexes, role.WithholdNotesRegexes...) } if role.CanAffectOtherAdmins != nil { *startingRole.CanAffectOtherAdmins = *role.CanAffectOtherAdmins @@ -38,113 +89,62 @@ func CollapseRolesIntoOne(roles ...Role) Role { if role.CanViewDeletedNotes != nil { *startingRole.CanViewDeletedNotes = *role.CanViewDeletedNotes } - if role.CanSupressInteractionsBetweenUsers != nil { - *startingRole.CanSupressInteractionsBetweenUsers = *role.CanSupressInteractionsBetweenUsers + if role.CanManageAvatarDecorations != nil { + *startingRole.CanManageAvatarDecorations = *role.CanManageAvatarDecorations } - if role.CanSendLocalNotes != nil { - *startingRole.CanSendLocalNotes = *role.CanSendLocalNotes + if role.CanSendFollowerOnlyNotes != nil { + *startingRole.CanSendFollowerOnlyNotes = *role.CanSendFollowerOnlyNotes + } + if role.BlockedUsers != nil { + startingRole.BlockedUsers = append(startingRole.BlockedUsers, role.BlockedUsers...) + } + if role.CanAssignRoles != nil { + *startingRole.CanAssignRoles = *role.CanAssignRoles + } + if role.CanManageCustomEmotes != nil { + *startingRole.CanManageCustomEmotes = *role.CanManageCustomEmotes + } + if role.CanSendPrivateNotes != nil { + *startingRole.CanSendPrivateNotes = *role.CanSendPrivateNotes } if role.CanFederateBsky != nil { *startingRole.CanFederateBsky = *role.CanFederateBsky } + if role.CanMentionOthers != nil { + *startingRole.CanMentionOthers = *role.CanMentionOthers + } + if role.AutoCwPostsText != nil { + *startingRole.AutoCwPostsText = *role.AutoCwPostsText + } + if role.CanSendMedia != nil { + *startingRole.CanSendMedia = *role.CanSendMedia + } + if role.CanIncludeLinks != nil { + *startingRole.CanIncludeLinks = *role.CanIncludeLinks + } + if role.MentionLimit != nil { + *startingRole.MentionLimit = *role.MentionLimit + } if role.AutoCwPosts != nil { *startingRole.AutoCwPosts = *role.AutoCwPosts } - if role.ScanCreatedPrivateNotes != nil { - *startingRole.ScanCreatedPrivateNotes = *role.ScanCreatedPrivateNotes - } - if role.CanDeleteNotes != nil { - *startingRole.CanDeleteNotes = *role.CanDeleteNotes - } - if role.CanSendCustomEmotes != nil { - *startingRole.CanSendCustomEmotes = *role.CanSendCustomEmotes - } - if role.CanIncludeSurvey != nil { - *startingRole.CanIncludeSurvey = *role.CanIncludeSurvey - } if role.ScanCreatedLocalNotes != nil { *startingRole.ScanCreatedLocalNotes = *role.ScanCreatedLocalNotes } if role.ScanCreatedFollowerOnlyNotes != nil { *startingRole.ScanCreatedFollowerOnlyNotes = *role.ScanCreatedFollowerOnlyNotes } - if role.CanOverwriteDisplayNames != nil { - *startingRole.CanOverwriteDisplayNames = *role.CanOverwriteDisplayNames - } - if role.AutoCwPostsText != nil { - *startingRole.AutoCwPostsText = *role.AutoCwPostsText - } - if role.DisallowInteractionsWith != nil { - startingRole.DisallowInteractionsWith = append(startingRole.DisallowInteractionsWith, role.DisallowInteractionsWith...) - } if role.CanRecoverDeletedNotes != nil { *startingRole.CanRecoverDeletedNotes = *role.CanRecoverDeletedNotes } - if role.CanSendFollowerOnlyNotes != nil { - *startingRole.CanSendFollowerOnlyNotes = *role.CanSendFollowerOnlyNotes - } - if role.CanSendPrivateNotes != nil { - *startingRole.CanSendPrivateNotes = *role.CanSendPrivateNotes - } - if role.CanSendReplies != nil { - *startingRole.CanSendReplies = *role.CanSendReplies - } - if role.CanChangeDisplayName != nil { - *startingRole.CanChangeDisplayName = *role.CanChangeDisplayName - } - if role.CanMentionOthers != nil { - *startingRole.CanMentionOthers = *role.CanMentionOthers - } - if role.CanManageAds != nil { - *startingRole.CanManageAds = *role.CanManageAds - } - if role.CanSendMedia != nil { - *startingRole.CanSendMedia = *role.CanSendMedia - } - if role.CanQuote != nil { - *startingRole.CanQuote = *role.CanQuote - } - if role.CanBoost != nil { - *startingRole.CanBoost = *role.CanBoost - } - if role.WithholdNotesBasedOnRegex != nil { - *startingRole.WithholdNotesBasedOnRegex = *role.WithholdNotesBasedOnRegex - } - if role.WithholdNotesRegexes != nil { - startingRole.WithholdNotesRegexes = append(startingRole.WithholdNotesRegexes, role.WithholdNotesRegexes...) - } - if role.CanManageCustomEmotes != nil { - *startingRole.CanManageCustomEmotes = *role.CanManageCustomEmotes - } if role.CanSendAnnouncements != nil { *startingRole.CanSendAnnouncements = *role.CanSendAnnouncements } - if role.CanSendCustomReactions != nil { - *startingRole.CanSendCustomReactions = *role.CanSendCustomReactions - } if role.CanFederateFedi != nil { *startingRole.CanFederateFedi = *role.CanFederateFedi } - if role.CanSubmitReports != nil { - *startingRole.CanSubmitReports = *role.CanSubmitReports - } - if role.CanLogin != nil { - *startingRole.CanLogin = *role.CanLogin - } - if role.CanAssignRoles != nil { - *startingRole.CanAssignRoles = *role.CanAssignRoles - } - if role.CanSendPublicNotes != nil { - *startingRole.CanSendPublicNotes = *role.CanSendPublicNotes - } - if role.FullAdmin != nil { - *startingRole.FullAdmin = *role.FullAdmin - } - if role.CanConfirmWithheldNotes != nil { - *startingRole.CanConfirmWithheldNotes = *role.CanConfirmWithheldNotes - } - if role.CanManageAvatarDecorations != nil { - *startingRole.CanManageAvatarDecorations = *role.CanManageAvatarDecorations + if role.HasMentionCountLimit != nil { + *startingRole.HasMentionCountLimit = *role.HasMentionCountLimit } } return startingRole @@ -157,47 +157,11 @@ func RoleDeepCopy(o Role) Role { n.Priority = o.Priority n.IsUserRole = o.IsUserRole n.IsBuiltIn = o.IsBuiltIn - if o.CanSendPublicNotes == nil { n.CanSendPublicNotes = nil } else { - t := *o.CanSendPublicNotes - n.CanSendPublicNotes = &t - } - if o.FullAdmin == nil { n.FullAdmin = nil } else { - t := *o.FullAdmin - n.FullAdmin = &t - } - if o.CanConfirmWithheldNotes == nil { n.CanConfirmWithheldNotes = nil } else { - t := *o.CanConfirmWithheldNotes - n.CanConfirmWithheldNotes = &t - } - if o.CanManageAvatarDecorations == nil { n.CanManageAvatarDecorations = nil } else { - t := *o.CanManageAvatarDecorations - n.CanManageAvatarDecorations = &t - } - if o.ScanCreatedPublicNotes == nil { n.ScanCreatedPublicNotes = nil } else { - t := *o.ScanCreatedPublicNotes - n.ScanCreatedPublicNotes = &t - } - if o.WithholdNotesForManualApproval == nil { n.WithholdNotesForManualApproval = nil } else { - t := *o.WithholdNotesForManualApproval - n.WithholdNotesForManualApproval = &t - } - if o.CanIncludeLinks == nil { n.CanIncludeLinks = nil } else { - t := *o.CanIncludeLinks - n.CanIncludeLinks = &t - } - n.BlockedUsers = slices.Clone(o.BlockedUsers) - if o.HasMentionCountLimit == nil { n.HasMentionCountLimit = nil } else { - t := *o.HasMentionCountLimit - n.HasMentionCountLimit = &t - } - if o.MentionLimit == nil { n.MentionLimit = nil } else { - t := *o.MentionLimit - n.MentionLimit = &t - } - if o.AutoNsfwMedia == nil { n.AutoNsfwMedia = nil } else { - t := *o.AutoNsfwMedia - n.AutoNsfwMedia = &t + if o.CanSubmitReports == nil { n.CanSubmitReports = nil } else { + t := *o.CanSubmitReports + n.CanSubmitReports = &t } + n.WithholdNotesRegexes = slices.Clone(o.WithholdNotesRegexes) if o.CanAffectOtherAdmins == nil { n.CanAffectOtherAdmins = nil } else { t := *o.CanAffectOtherAdmins n.CanAffectOtherAdmins = &t @@ -206,50 +170,31 @@ func RoleDeepCopy(o Role) Role { t := *o.CanViewDeletedNotes n.CanViewDeletedNotes = &t } - if o.CanDeleteNotes == nil { n.CanDeleteNotes = nil } else { - t := *o.CanDeleteNotes - n.CanDeleteNotes = &t + if o.CanManageAvatarDecorations == nil { n.CanManageAvatarDecorations = nil } else { + t := *o.CanManageAvatarDecorations + n.CanManageAvatarDecorations = &t } - if o.CanSupressInteractionsBetweenUsers == nil { n.CanSupressInteractionsBetweenUsers = nil } else { - t := *o.CanSupressInteractionsBetweenUsers - n.CanSupressInteractionsBetweenUsers = &t + if o.CanSendFollowerOnlyNotes == nil { n.CanSendFollowerOnlyNotes = nil } else { + t := *o.CanSendFollowerOnlyNotes + n.CanSendFollowerOnlyNotes = &t } - if o.CanSendLocalNotes == nil { n.CanSendLocalNotes = nil } else { - t := *o.CanSendLocalNotes - n.CanSendLocalNotes = &t + n.BlockedUsers = slices.Clone(o.BlockedUsers) + if o.CanAssignRoles == nil { n.CanAssignRoles = nil } else { + t := *o.CanAssignRoles + n.CanAssignRoles = &t + } + if o.CanManageCustomEmotes == nil { n.CanManageCustomEmotes = nil } else { + t := *o.CanManageCustomEmotes + n.CanManageCustomEmotes = &t + } + if o.CanSendPrivateNotes == nil { n.CanSendPrivateNotes = nil } else { + t := *o.CanSendPrivateNotes + n.CanSendPrivateNotes = &t } if o.CanFederateBsky == nil { n.CanFederateBsky = nil } else { t := *o.CanFederateBsky n.CanFederateBsky = &t } - if o.AutoCwPosts == nil { n.AutoCwPosts = nil } else { - t := *o.AutoCwPosts - n.AutoCwPosts = &t - } - if o.ScanCreatedPrivateNotes == nil { n.ScanCreatedPrivateNotes = nil } else { - t := *o.ScanCreatedPrivateNotes - n.ScanCreatedPrivateNotes = &t - } - if o.CanOverwriteDisplayNames == nil { n.CanOverwriteDisplayNames = nil } else { - t := *o.CanOverwriteDisplayNames - n.CanOverwriteDisplayNames = &t - } - if o.CanSendCustomEmotes == nil { n.CanSendCustomEmotes = nil } else { - t := *o.CanSendCustomEmotes - n.CanSendCustomEmotes = &t - } - if o.CanIncludeSurvey == nil { n.CanIncludeSurvey = nil } else { - t := *o.CanIncludeSurvey - n.CanIncludeSurvey = &t - } - if o.ScanCreatedLocalNotes == nil { n.ScanCreatedLocalNotes = nil } else { - t := *o.ScanCreatedLocalNotes - n.ScanCreatedLocalNotes = &t - } - if o.ScanCreatedFollowerOnlyNotes == nil { n.ScanCreatedFollowerOnlyNotes = nil } else { - t := *o.ScanCreatedFollowerOnlyNotes - n.ScanCreatedFollowerOnlyNotes = &t - } if o.CanMentionOthers == nil { n.CanMentionOthers = nil } else { t := *o.CanMentionOthers n.CanMentionOthers = &t @@ -258,79 +203,134 @@ func RoleDeepCopy(o Role) Role { t := *o.AutoCwPostsText n.AutoCwPostsText = &t } - n.DisallowInteractionsWith = slices.Clone(o.DisallowInteractionsWith) - if o.CanRecoverDeletedNotes == nil { n.CanRecoverDeletedNotes = nil } else { - t := *o.CanRecoverDeletedNotes - n.CanRecoverDeletedNotes = &t - } - if o.CanSendFollowerOnlyNotes == nil { n.CanSendFollowerOnlyNotes = nil } else { - t := *o.CanSendFollowerOnlyNotes - n.CanSendFollowerOnlyNotes = &t - } - if o.CanSendPrivateNotes == nil { n.CanSendPrivateNotes = nil } else { - t := *o.CanSendPrivateNotes - n.CanSendPrivateNotes = &t - } - if o.CanSendReplies == nil { n.CanSendReplies = nil } else { - t := *o.CanSendReplies - n.CanSendReplies = &t - } - if o.CanChangeDisplayName == nil { n.CanChangeDisplayName = nil } else { - t := *o.CanChangeDisplayName - n.CanChangeDisplayName = &t - } - n.WithholdNotesRegexes = slices.Clone(o.WithholdNotesRegexes) - if o.CanManageAds == nil { n.CanManageAds = nil } else { - t := *o.CanManageAds - n.CanManageAds = &t - } if o.CanSendMedia == nil { n.CanSendMedia = nil } else { t := *o.CanSendMedia n.CanSendMedia = &t } - if o.CanQuote == nil { n.CanQuote = nil } else { - t := *o.CanQuote - n.CanQuote = &t + if o.CanIncludeLinks == nil { n.CanIncludeLinks = nil } else { + t := *o.CanIncludeLinks + n.CanIncludeLinks = &t } - if o.CanBoost == nil { n.CanBoost = nil } else { - t := *o.CanBoost - n.CanBoost = &t + if o.MentionLimit == nil { n.MentionLimit = nil } else { + t := *o.MentionLimit + n.MentionLimit = &t } - if o.WithholdNotesBasedOnRegex == nil { n.WithholdNotesBasedOnRegex = nil } else { - t := *o.WithholdNotesBasedOnRegex - n.WithholdNotesBasedOnRegex = &t + if o.AutoCwPosts == nil { n.AutoCwPosts = nil } else { + t := *o.AutoCwPosts + n.AutoCwPosts = &t } - if o.CanAssignRoles == nil { n.CanAssignRoles = nil } else { - t := *o.CanAssignRoles - n.CanAssignRoles = &t + if o.ScanCreatedLocalNotes == nil { n.ScanCreatedLocalNotes = nil } else { + t := *o.ScanCreatedLocalNotes + n.ScanCreatedLocalNotes = &t } - if o.CanManageCustomEmotes == nil { n.CanManageCustomEmotes = nil } else { - t := *o.CanManageCustomEmotes - n.CanManageCustomEmotes = &t + if o.ScanCreatedFollowerOnlyNotes == nil { n.ScanCreatedFollowerOnlyNotes = nil } else { + t := *o.ScanCreatedFollowerOnlyNotes + n.ScanCreatedFollowerOnlyNotes = &t + } + if o.CanRecoverDeletedNotes == nil { n.CanRecoverDeletedNotes = nil } else { + t := *o.CanRecoverDeletedNotes + n.CanRecoverDeletedNotes = &t } if o.CanSendAnnouncements == nil { n.CanSendAnnouncements = nil } else { t := *o.CanSendAnnouncements n.CanSendAnnouncements = &t } - if o.CanSendCustomReactions == nil { n.CanSendCustomReactions = nil } else { - t := *o.CanSendCustomReactions - n.CanSendCustomReactions = &t - } if o.CanFederateFedi == nil { n.CanFederateFedi = nil } else { t := *o.CanFederateFedi n.CanFederateFedi = &t } - if o.CanSubmitReports == nil { n.CanSubmitReports = nil } else { - t := *o.CanSubmitReports - n.CanSubmitReports = &t + if o.HasMentionCountLimit == nil { n.HasMentionCountLimit = nil } else { + t := *o.HasMentionCountLimit + n.HasMentionCountLimit = &t + } + if o.CanSendReplies == nil { n.CanSendReplies = nil } else { + t := *o.CanSendReplies + n.CanSendReplies = &t + } + if o.CanBoost == nil { n.CanBoost = nil } else { + t := *o.CanBoost + n.CanBoost = &t + } + if o.AutoNsfwMedia == nil { n.AutoNsfwMedia = nil } else { + t := *o.AutoNsfwMedia + n.AutoNsfwMedia = &t + } + if o.WithholdNotesForManualApproval == nil { n.WithholdNotesForManualApproval = nil } else { + t := *o.WithholdNotesForManualApproval + n.WithholdNotesForManualApproval = &t + } + if o.WithholdNotesBasedOnRegex == nil { n.WithholdNotesBasedOnRegex = nil } else { + t := *o.WithholdNotesBasedOnRegex + n.WithholdNotesBasedOnRegex = &t + } + if o.CanSendCustomReactions == nil { n.CanSendCustomReactions = nil } else { + t := *o.CanSendCustomReactions + n.CanSendCustomReactions = &t + } + if o.CanSendLocalNotes == nil { n.CanSendLocalNotes = nil } else { + t := *o.CanSendLocalNotes + n.CanSendLocalNotes = &t + } + n.DisallowInteractionsWith = slices.Clone(o.DisallowInteractionsWith) + if o.CanDeleteNotes == nil { n.CanDeleteNotes = nil } else { + t := *o.CanDeleteNotes + n.CanDeleteNotes = &t + } + if o.CanSupressInteractionsBetweenUsers == nil { n.CanSupressInteractionsBetweenUsers = nil } else { + t := *o.CanSupressInteractionsBetweenUsers + n.CanSupressInteractionsBetweenUsers = &t + } + if o.CanSendPublicNotes == nil { n.CanSendPublicNotes = nil } else { + t := *o.CanSendPublicNotes + n.CanSendPublicNotes = &t + } + if o.ScanCreatedPrivateNotes == nil { n.ScanCreatedPrivateNotes = nil } else { + t := *o.ScanCreatedPrivateNotes + n.ScanCreatedPrivateNotes = &t + } + if o.ScanCreatedPublicNotes == nil { n.ScanCreatedPublicNotes = nil } else { + t := *o.ScanCreatedPublicNotes + n.ScanCreatedPublicNotes = &t + } + if o.CanConfirmWithheldNotes == nil { n.CanConfirmWithheldNotes = nil } else { + t := *o.CanConfirmWithheldNotes + n.CanConfirmWithheldNotes = &t + } + if o.CanManageAds == nil { n.CanManageAds = nil } else { + t := *o.CanManageAds + n.CanManageAds = &t + } + if o.CanIncludeSurvey == nil { n.CanIncludeSurvey = nil } else { + t := *o.CanIncludeSurvey + n.CanIncludeSurvey = &t } if o.CanLogin == nil { n.CanLogin = nil } else { t := *o.CanLogin n.CanLogin = &t } + if o.CanChangeDisplayName == nil { n.CanChangeDisplayName = nil } else { + t := *o.CanChangeDisplayName + n.CanChangeDisplayName = &t + } + if o.FullAdmin == nil { n.FullAdmin = nil } else { + t := *o.FullAdmin + n.FullAdmin = &t + } + if o.CanOverwriteDisplayNames == nil { n.CanOverwriteDisplayNames = nil } else { + t := *o.CanOverwriteDisplayNames + n.CanOverwriteDisplayNames = &t + } + if o.CanSendCustomEmotes == nil { n.CanSendCustomEmotes = nil } else { + t := *o.CanSendCustomEmotes + n.CanSendCustomEmotes = &t + } + if o.CanQuote == nil { n.CanQuote = nil } else { + t := *o.CanQuote + n.CanQuote = &t + } return n } func CompareRoles(a, b *Role) bool { - return (a.CanSendCustomReactions == nil || b.CanSendCustomReactions == nil || a.CanSendCustomReactions == b.CanSendCustomReactions) && (a.CanFederateFedi == nil || b.CanFederateFedi == nil || a.CanFederateFedi == b.CanFederateFedi) && (a.CanSubmitReports == nil || b.CanSubmitReports == nil || a.CanSubmitReports == b.CanSubmitReports) && (a.CanLogin == nil || b.CanLogin == nil || a.CanLogin == b.CanLogin) && (a.CanAssignRoles == nil || b.CanAssignRoles == nil || a.CanAssignRoles == b.CanAssignRoles) && (a.CanManageCustomEmotes == nil || b.CanManageCustomEmotes == nil || a.CanManageCustomEmotes == b.CanManageCustomEmotes) && (a.CanSendAnnouncements == nil || b.CanSendAnnouncements == nil || a.CanSendAnnouncements == b.CanSendAnnouncements) && (a.CanSendPublicNotes == nil || b.CanSendPublicNotes == nil || a.CanSendPublicNotes == b.CanSendPublicNotes) && (a.FullAdmin == nil || b.FullAdmin == nil || a.FullAdmin == b.FullAdmin) && (a.CanConfirmWithheldNotes == nil || b.CanConfirmWithheldNotes == nil || a.CanConfirmWithheldNotes == b.CanConfirmWithheldNotes) && (a.CanManageAvatarDecorations == nil || b.CanManageAvatarDecorations == nil || a.CanManageAvatarDecorations == b.CanManageAvatarDecorations) && (a.CanIncludeLinks == nil || b.CanIncludeLinks == nil || a.CanIncludeLinks == b.CanIncludeLinks) && (a.BlockedUsers == nil || b.BlockedUsers == nil || sliceutils.CompareUnordered(a.BlockedUsers,b.BlockedUsers)) && (a.HasMentionCountLimit == nil || b.HasMentionCountLimit == nil || a.HasMentionCountLimit == b.HasMentionCountLimit) && (a.MentionLimit == nil || b.MentionLimit == nil || a.MentionLimit == b.MentionLimit) && (a.ScanCreatedPublicNotes == nil || b.ScanCreatedPublicNotes == nil || a.ScanCreatedPublicNotes == b.ScanCreatedPublicNotes) && (a.WithholdNotesForManualApproval == nil || b.WithholdNotesForManualApproval == nil || a.WithholdNotesForManualApproval == b.WithholdNotesForManualApproval) && (a.AutoNsfwMedia == nil || b.AutoNsfwMedia == nil || a.AutoNsfwMedia == b.AutoNsfwMedia) && (a.CanAffectOtherAdmins == nil || b.CanAffectOtherAdmins == nil || a.CanAffectOtherAdmins == b.CanAffectOtherAdmins) && (a.CanViewDeletedNotes == nil || b.CanViewDeletedNotes == nil || a.CanViewDeletedNotes == b.CanViewDeletedNotes) && (a.CanSendLocalNotes == nil || b.CanSendLocalNotes == nil || a.CanSendLocalNotes == b.CanSendLocalNotes) && (a.CanFederateBsky == nil || b.CanFederateBsky == nil || a.CanFederateBsky == b.CanFederateBsky) && (a.AutoCwPosts == nil || b.AutoCwPosts == nil || a.AutoCwPosts == b.AutoCwPosts) && (a.ScanCreatedPrivateNotes == nil || b.ScanCreatedPrivateNotes == nil || a.ScanCreatedPrivateNotes == b.ScanCreatedPrivateNotes) && (a.CanDeleteNotes == nil || b.CanDeleteNotes == nil || a.CanDeleteNotes == b.CanDeleteNotes) && (a.CanSupressInteractionsBetweenUsers == nil || b.CanSupressInteractionsBetweenUsers == nil || a.CanSupressInteractionsBetweenUsers == b.CanSupressInteractionsBetweenUsers) && (a.CanSendCustomEmotes == nil || b.CanSendCustomEmotes == nil || a.CanSendCustomEmotes == b.CanSendCustomEmotes) && (a.CanIncludeSurvey == nil || b.CanIncludeSurvey == nil || a.CanIncludeSurvey == b.CanIncludeSurvey) && (a.ScanCreatedLocalNotes == nil || b.ScanCreatedLocalNotes == nil || a.ScanCreatedLocalNotes == b.ScanCreatedLocalNotes) && (a.ScanCreatedFollowerOnlyNotes == nil || b.ScanCreatedFollowerOnlyNotes == nil || a.ScanCreatedFollowerOnlyNotes == b.ScanCreatedFollowerOnlyNotes) && (a.CanOverwriteDisplayNames == nil || b.CanOverwriteDisplayNames == nil || a.CanOverwriteDisplayNames == b.CanOverwriteDisplayNames) && (a.CanRecoverDeletedNotes == nil || b.CanRecoverDeletedNotes == nil || a.CanRecoverDeletedNotes == b.CanRecoverDeletedNotes) && (a.CanSendFollowerOnlyNotes == nil || b.CanSendFollowerOnlyNotes == nil || a.CanSendFollowerOnlyNotes == b.CanSendFollowerOnlyNotes) && (a.CanSendPrivateNotes == nil || b.CanSendPrivateNotes == nil || a.CanSendPrivateNotes == b.CanSendPrivateNotes) && (a.CanSendReplies == nil || b.CanSendReplies == nil || a.CanSendReplies == b.CanSendReplies) && (a.CanChangeDisplayName == nil || b.CanChangeDisplayName == nil || a.CanChangeDisplayName == b.CanChangeDisplayName) && (a.CanMentionOthers == nil || b.CanMentionOthers == nil || a.CanMentionOthers == b.CanMentionOthers) && (a.AutoCwPostsText == nil || b.AutoCwPostsText == nil || a.AutoCwPostsText == b.AutoCwPostsText) && (a.DisallowInteractionsWith == nil || b.DisallowInteractionsWith == nil || sliceutils.CompareUnordered(a.DisallowInteractionsWith,b.DisallowInteractionsWith)) && (a.CanSendMedia == nil || b.CanSendMedia == nil || a.CanSendMedia == b.CanSendMedia) && (a.CanQuote == nil || b.CanQuote == nil || a.CanQuote == b.CanQuote) && (a.CanBoost == nil || b.CanBoost == nil || a.CanBoost == b.CanBoost) && (a.WithholdNotesBasedOnRegex == nil || b.WithholdNotesBasedOnRegex == nil || a.WithholdNotesBasedOnRegex == b.WithholdNotesBasedOnRegex) && (a.WithholdNotesRegexes == nil || b.WithholdNotesRegexes == nil || sliceutils.CompareUnordered(a.WithholdNotesRegexes,b.WithholdNotesRegexes)) && (a.CanManageAds == nil || b.CanManageAds == nil || a.CanManageAds == b.CanManageAds) && (a == nil || b == nil || a.CanManageAds == b.CanManageAds) + return (a.CanSendLocalNotes == nil || b.CanSendLocalNotes == nil || a.CanSendLocalNotes == b.CanSendLocalNotes) && (a.CanSendReplies == nil || b.CanSendReplies == nil || a.CanSendReplies == b.CanSendReplies) && (a.CanBoost == nil || b.CanBoost == nil || a.CanBoost == b.CanBoost) && (a.AutoNsfwMedia == nil || b.AutoNsfwMedia == nil || a.AutoNsfwMedia == b.AutoNsfwMedia) && (a.WithholdNotesForManualApproval == nil || b.WithholdNotesForManualApproval == nil || a.WithholdNotesForManualApproval == b.WithholdNotesForManualApproval) && (a.WithholdNotesBasedOnRegex == nil || b.WithholdNotesBasedOnRegex == nil || a.WithholdNotesBasedOnRegex == b.WithholdNotesBasedOnRegex) && (a.CanSendCustomReactions == nil || b.CanSendCustomReactions == nil || a.CanSendCustomReactions == b.CanSendCustomReactions) && (a.ScanCreatedPrivateNotes == nil || b.ScanCreatedPrivateNotes == nil || a.ScanCreatedPrivateNotes == b.ScanCreatedPrivateNotes) && (a.DisallowInteractionsWith == nil || b.DisallowInteractionsWith == nil || sliceutils.CompareUnordered(a.DisallowInteractionsWith,b.DisallowInteractionsWith)) && (a.CanDeleteNotes == nil || b.CanDeleteNotes == nil || a.CanDeleteNotes == b.CanDeleteNotes) && (a.CanSupressInteractionsBetweenUsers == nil || b.CanSupressInteractionsBetweenUsers == nil || a.CanSupressInteractionsBetweenUsers == b.CanSupressInteractionsBetweenUsers) && (a.CanSendPublicNotes == nil || b.CanSendPublicNotes == nil || a.CanSendPublicNotes == b.CanSendPublicNotes) && (a.CanLogin == nil || b.CanLogin == nil || a.CanLogin == b.CanLogin) && (a.ScanCreatedPublicNotes == nil || b.ScanCreatedPublicNotes == nil || a.ScanCreatedPublicNotes == b.ScanCreatedPublicNotes) && (a.CanConfirmWithheldNotes == nil || b.CanConfirmWithheldNotes == nil || a.CanConfirmWithheldNotes == b.CanConfirmWithheldNotes) && (a.CanManageAds == nil || b.CanManageAds == nil || a.CanManageAds == b.CanManageAds) && (a.CanIncludeSurvey == nil || b.CanIncludeSurvey == nil || a.CanIncludeSurvey == b.CanIncludeSurvey) && (a.CanQuote == nil || b.CanQuote == nil || a.CanQuote == b.CanQuote) && (a.CanChangeDisplayName == nil || b.CanChangeDisplayName == nil || a.CanChangeDisplayName == b.CanChangeDisplayName) && (a.FullAdmin == nil || b.FullAdmin == nil || a.FullAdmin == b.FullAdmin) && (a.CanOverwriteDisplayNames == nil || b.CanOverwriteDisplayNames == nil || a.CanOverwriteDisplayNames == b.CanOverwriteDisplayNames) && (a.CanSendCustomEmotes == nil || b.CanSendCustomEmotes == nil || a.CanSendCustomEmotes == b.CanSendCustomEmotes) && (a.BlockedUsers == nil || b.BlockedUsers == nil || sliceutils.CompareUnordered(a.BlockedUsers,b.BlockedUsers)) && (a.CanSubmitReports == nil || b.CanSubmitReports == nil || a.CanSubmitReports == b.CanSubmitReports) && (a.WithholdNotesRegexes == nil || b.WithholdNotesRegexes == nil || sliceutils.CompareUnordered(a.WithholdNotesRegexes,b.WithholdNotesRegexes)) && (a.CanAffectOtherAdmins == nil || b.CanAffectOtherAdmins == nil || a.CanAffectOtherAdmins == b.CanAffectOtherAdmins) && (a.CanViewDeletedNotes == nil || b.CanViewDeletedNotes == nil || a.CanViewDeletedNotes == b.CanViewDeletedNotes) && (a.CanManageAvatarDecorations == nil || b.CanManageAvatarDecorations == nil || a.CanManageAvatarDecorations == b.CanManageAvatarDecorations) && (a.CanSendFollowerOnlyNotes == nil || b.CanSendFollowerOnlyNotes == nil || a.CanSendFollowerOnlyNotes == b.CanSendFollowerOnlyNotes) && (a.CanFederateBsky == nil || b.CanFederateBsky == nil || a.CanFederateBsky == b.CanFederateBsky) && (a.CanAssignRoles == nil || b.CanAssignRoles == nil || a.CanAssignRoles == b.CanAssignRoles) && (a.CanManageCustomEmotes == nil || b.CanManageCustomEmotes == nil || a.CanManageCustomEmotes == b.CanManageCustomEmotes) && (a.CanSendPrivateNotes == nil || b.CanSendPrivateNotes == nil || a.CanSendPrivateNotes == b.CanSendPrivateNotes) && (a.CanIncludeLinks == nil || b.CanIncludeLinks == nil || a.CanIncludeLinks == b.CanIncludeLinks) && (a.CanMentionOthers == nil || b.CanMentionOthers == nil || a.CanMentionOthers == b.CanMentionOthers) && (a.AutoCwPostsText == nil || b.AutoCwPostsText == nil || a.AutoCwPostsText == b.AutoCwPostsText) && (a.CanSendMedia == nil || b.CanSendMedia == nil || a.CanSendMedia == b.CanSendMedia) && (a.HasMentionCountLimit == nil || b.HasMentionCountLimit == nil || a.HasMentionCountLimit == b.HasMentionCountLimit) && (a.MentionLimit == nil || b.MentionLimit == nil || a.MentionLimit == b.MentionLimit) && (a.AutoCwPosts == nil || b.AutoCwPosts == nil || a.AutoCwPosts == b.AutoCwPosts) && (a.ScanCreatedLocalNotes == nil || b.ScanCreatedLocalNotes == nil || a.ScanCreatedLocalNotes == b.ScanCreatedLocalNotes) && (a.ScanCreatedFollowerOnlyNotes == nil || b.ScanCreatedFollowerOnlyNotes == nil || a.ScanCreatedFollowerOnlyNotes == b.ScanCreatedFollowerOnlyNotes) && (a.CanRecoverDeletedNotes == nil || b.CanRecoverDeletedNotes == nil || a.CanRecoverDeletedNotes == b.CanRecoverDeletedNotes) && (a.CanSendAnnouncements == nil || b.CanSendAnnouncements == nil || a.CanSendAnnouncements == b.CanSendAnnouncements) && (a.CanFederateFedi == nil || b.CanFederateFedi == nil || a.CanFederateFedi == b.CanFederateFedi) && (a == nil || b == nil || a.CanFederateFedi == b.CanFederateFedi) } \ No newline at end of file