Gracefully handle the elephant

This commit is contained in:
r 2020-02-26 11:27:42 +00:00
parent c41f9272f9
commit d5230852cf
3 changed files with 31 additions and 21 deletions

View file

@ -15,26 +15,26 @@ type AccountPleroma struct {
// Account hold information for mastodon account. // Account hold information for mastodon account.
type Account struct { type Account struct {
ID string `json:"id"` ID string `json:"id"`
Username string `json:"username"` Username string `json:"username"`
Acct string `json:"acct"` Acct string `json:"acct"`
DisplayName string `json:"display_name"` DisplayName string `json:"display_name"`
Locked bool `json:"locked"` Locked bool `json:"locked"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
FollowersCount int64 `json:"followers_count"` FollowersCount int64 `json:"followers_count"`
FollowingCount int64 `json:"following_count"` FollowingCount int64 `json:"following_count"`
StatusesCount int64 `json:"statuses_count"` StatusesCount int64 `json:"statuses_count"`
Note string `json:"note"` Note string `json:"note"`
URL string `json:"url"` URL string `json:"url"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
AvatarStatic string `json:"avatar_static"` AvatarStatic string `json:"avatar_static"`
Header string `json:"header"` Header string `json:"header"`
HeaderStatic string `json:"header_static"` HeaderStatic string `json:"header_static"`
Emojis []Emoji `json:"emojis"` Emojis []Emoji `json:"emojis"`
Moved *Account `json:"moved"` Moved *Account `json:"moved"`
Fields []Field `json:"fields"` Fields []Field `json:"fields"`
Bot bool `json:"bot"` Bot bool `json:"bot"`
Pleroma AccountPleroma `json:"pleroma"` Pleroma *AccountPleroma `json:"pleroma"`
} }
// Field is a Mastodon account profile field. // Field is a Mastodon account profile field.
@ -60,6 +60,15 @@ func (c *Client) GetAccount(ctx context.Context, id string) (*Account, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if account.Pleroma == nil {
rs, err := c.GetAccountRelationships(ctx, []string{id})
if err != nil {
return nil, err
}
if len(rs) > 0 {
account.Pleroma = &AccountPleroma{*rs[0]}
}
}
return &account, nil return &account, nil
} }

View file

@ -339,6 +339,7 @@ func (svc *service) ServeThreadPage(ctx context.Context, c *model.Client,
for i := range statuses { for i := range statuses {
statuses[i].ShowReplies = true statuses[i].ShowReplies = true
statuses[i].ReplyMap = replies statuses[i].ReplyMap = replies
statuses[i].ReplyNumber = i
addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i+1) addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i+1)
} }

View file

@ -56,7 +56,7 @@
{{if .InReplyToID}} {{if .InReplyToID}}
<div class="status-reply-to"> <div class="status-reply-to">
<a class="status-reply-to-link" href="{{if not .ShowReplies}}/thread/{{.InReplyToID}}{{end}}#status-{{.InReplyToID}}"> <a class="status-reply-to-link" href="{{if not .ShowReplies}}/thread/{{.InReplyToID}}{{end}}#status-{{.InReplyToID}}">
reply to {{.Pleroma.InReplyToAccountAcct}} in reply to {{if .Pleroma.InReplyToAccountAcct}}{{.Pleroma.InReplyToAccountAcct}}{{else if .ReplyNumber}}#{{.ReplyNumber}}{{else}}{{.InReplyToID}}{{end}}
</a> </a>
</div> </div>
{{if index .ReplyMap .ID}} <span class="status-reply-info-divider"> - </span> {{end}} {{if index .ReplyMap .ID}} <span class="status-reply-info-divider"> - </span> {{end}}