From bdd1eed6f7cb9055606f0be0cb5b536b803fbbcc Mon Sep 17 00:00:00 2001 From: Gizmo Date: Mon, 11 Dec 2023 14:08:16 +0800 Subject: [PATCH] fix: models.CredentialAccount.Source.Privacy --- models/Account.go | 25 +++++---------------- models/Instance.go | 2 +- models/MkUser.go | 47 ++++++++++++++++++++------------------- proxy/misskey/accounts.go | 1 + 4 files changed, 32 insertions(+), 43 deletions(-) diff --git a/models/Account.go b/models/Account.go index 02c3403..8753e3d 100644 --- a/models/Account.go +++ b/models/Account.go @@ -1,18 +1,5 @@ package models -type PostPrivacy = string - -const ( - // PostPrivacyPublic Public post - PostPrivacyPublic PostPrivacy = "public" - // PostPrivacyUnlisted Unlisted post - PostPrivacyUnlisted PostPrivacy = "unlisted" - // PostPrivacyPrivate Followers-only post - PostPrivacyPrivate PostPrivacy = "private" - // PostPrivacyDirect Direct post - PostPrivacyDirect PostPrivacy = "direct" -) - type Account struct { ID string `json:"id"` Username string `json:"username"` @@ -49,12 +36,12 @@ type AccountField struct { type CredentialAccount struct { Account Source struct { - Privacy PostPrivacy `json:"privacy"` - Sensitive bool `json:"sensitive"` - Language string `json:"language"` - Note string `json:"note"` - Fields []AccountField `json:"fields"` - FollowRequestsCount int `json:"follow_requests_count"` + Privacy StatusVisibility `json:"privacy"` + Sensitive bool `json:"sensitive"` + Language string `json:"language"` + Note string `json:"note"` + Fields []AccountField `json:"fields"` + FollowRequestsCount int `json:"follow_requests_count"` } `json:"source"` Role *struct { Id string `json:"id"` diff --git a/models/Instance.go b/models/Instance.go index df8d702..6734bd1 100644 --- a/models/Instance.go +++ b/models/Instance.go @@ -29,7 +29,7 @@ type ( SupportedMimeTypes []string `json:"supported_mime_types"` } `json:"media_attachments"` } `json:"configuration"` - ContactAccount Account `json:"contact_account"` + ContactAccount *Account `json:"contact_account,omitempty"` Rules []InstanceRule `json:"rules"` } InstanceUrls struct { diff --git a/models/MkUser.go b/models/MkUser.go index 64a89e3..c53a4b2 100644 --- a/models/MkUser.go +++ b/models/MkUser.go @@ -10,29 +10,30 @@ import ( ) type MkUser struct { - ID string `json:"id"` - Username string `json:"username"` - Name string `json:"name"` - Host *string `json:"host,omitempty"` - Location *string `json:"location"` - Description *string `json:"description"` - IsBot bool `json:"isBot"` - IsLocked bool `json:"isLocked"` - CreatedAt string `json:"createdAt,omitempty"` - UpdatedAt *string `json:"updatedAt"` - FollowersCount int `json:"followersCount"` - FollowingCount int `json:"followingCount"` - NotesCount int `json:"notesCount"` - AvatarUrl string `json:"avatarUrl"` - BannerUrl string `json:"bannerUrl"` - Fields []AccountField `json:"fields"` - Instance MkInstance `json:"instance"` - Mentions []string `json:"mentions"` - IsMuted bool `json:"isMuted"` - IsBlocked bool `json:"isBlocked"` - IsBlocking bool `json:"isBlocking"` - IsFollowing bool `json:"isFollowing"` - IsFollowed bool `json:"isFollowed"` + ID string `json:"id"` + Username string `json:"username"` + Name string `json:"name"` + Host *string `json:"host,omitempty"` + Location *string `json:"location"` + Description *string `json:"description"` + IsBot bool `json:"isBot"` + IsLocked bool `json:"isLocked"` + CreatedAt string `json:"createdAt,omitempty"` + UpdatedAt *string `json:"updatedAt"` + FollowersCount int `json:"followersCount"` + FollowingCount int `json:"followingCount"` + NotesCount int `json:"notesCount"` + AvatarUrl string `json:"avatarUrl"` + BannerUrl string `json:"bannerUrl"` + Fields []AccountField `json:"fields"` + Instance MkInstance `json:"instance"` + Mentions []string `json:"mentions"` + IsMuted bool `json:"isMuted"` + IsBlocked bool `json:"isBlocked"` + IsBlocking bool `json:"isBlocking"` + IsFollowing bool `json:"isFollowing"` + IsFollowed bool `json:"isFollowed"` + FfVisibility MkNoteVisibility `json:"ffVisibility,omitempty"` } type MkInstance struct { diff --git a/proxy/misskey/accounts.go b/proxy/misskey/accounts.go index f32999f..376e985 100644 --- a/proxy/misskey/accounts.go +++ b/proxy/misskey/accounts.go @@ -104,6 +104,7 @@ func VerifyCredentials(ctx misstodon.Context) (models.CredentialAccount, error) info.Source.Note = *result.Description } info.Source.Fields = info.Account.Fields + info.Source.Privacy = result.FfVisibility.ToStatusVisibility() return info, nil }