separate misskey struct; small handler for renote

This commit is contained in:
localhost_frssoft 2023-11-15 01:51:03 +03:00
parent 5d4aab1d58
commit baf388cb42
2 changed files with 35 additions and 23 deletions

27
mastodon/misskey.go Normal file
View File

@ -0,0 +1,27 @@
package mastodon
type MisskeyStatus struct {
ID string `json:"id"`
User AccountMisskey `json:"user"`
Renote *MisskeyStatus `json:"renote"`
CreatedAt CreatedAt `json:"createdAt"`
Visibility string `json:"visibility"`
CW string `json:"cw"`
URL string `json:"url"`
Text string `json:"text"`
Files []Attachment `json:"files"`
RenoteCount int64 `json:"renoteCount"`
RepliesCount int64 `json:"repliesCount"`
Reactions map[string]int `json:"reactions"`
}
type AccountMisskey struct {
ID string `json:"id"`
Host string `json:"host"`
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatarUrl"`
IsBot bool `json:"isBot"`
}

View File

@ -92,29 +92,6 @@ type Status struct {
RetweetedByID string `json:"retweeted_by_id"`
}
type MisskeyStatus struct {
ID string `json:"id"`
User AccountMisskey `json:"user"`
CreatedAt CreatedAt `json:"createdAt"`
Visibility string `json:"visibility"`
CW string `json:"cw"`
URL string `json:"url"`
Text string `json:"text"`
Files []Attachment `json:"files"`
RenoteCount int64 `json:"renoteCount"`
RepliesCount int64 `json:"repliesCount"`
Reactions map[string]int `json:"reactions"`
}
type AccountMisskey struct {
ID string `json:"id"`
Host string `json:"host"`
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatarUrl"`
IsBot bool `json:"isBot"`
}
// Context hold information for mastodon context.
type Context struct {
Ancestors []*Status `json:"ancestors"`
@ -352,6 +329,14 @@ func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instan
for _, statusMisskey := range misskeyData {
var status Status
status.ID = statusMisskey.ID
if statusMisskey.Renote != nil {
// small handle for strange reblogs in misskey
// handle as quoted post because akkoma/pleroma makes same
var quote Status
quote.ID = statusMisskey.Renote.ID
quote.Content = strings.Replace(statusMisskey.Renote.Text, "\n", "<br>", -1)
status.Pleroma.Quote = &quote
}
status.Account.ID = statusMisskey.User.ID
status.Account.DisplayName = statusMisskey.User.Name
if statusMisskey.User.Host != "" {