diff options
author | r <r@freesoftwareextremist.com> | 2020-02-26 11:27:42 +0000 |
---|---|---|
committer | r <r@freesoftwareextremist.com> | 2020-02-26 11:27:42 +0000 |
commit | d5230852cf4da238a0d3acb219f9049e9d669969 (patch) | |
tree | 86b1a01e87b1cc4ca6c386fa93c26dd21bd5ba13 | |
parent | c41f9272f919644f66148cafb179a4df0e7eae17 (diff) | |
download | bloat-d5230852cf4da238a0d3acb219f9049e9d669969.tar.gz bloat-d5230852cf4da238a0d3acb219f9049e9d669969.zip |
Gracefully handle the elephant
-rw-r--r-- | mastodon/accounts.go | 49 | ||||
-rw-r--r-- | service/service.go | 1 | ||||
-rw-r--r-- | templates/status.tmpl | 2 |
3 files changed, 31 insertions, 21 deletions
diff --git a/mastodon/accounts.go b/mastodon/accounts.go index 86581ec..c02f0bd 100644 --- a/mastodon/accounts.go +++ b/mastodon/accounts.go @@ -15,26 +15,26 @@ type AccountPleroma struct { // Account hold information for mastodon account. type Account struct { - ID string `json:"id"` - Username string `json:"username"` - Acct string `json:"acct"` - DisplayName string `json:"display_name"` - Locked bool `json:"locked"` - CreatedAt time.Time `json:"created_at"` - FollowersCount int64 `json:"followers_count"` - FollowingCount int64 `json:"following_count"` - StatusesCount int64 `json:"statuses_count"` - Note string `json:"note"` - URL string `json:"url"` - Avatar string `json:"avatar"` - AvatarStatic string `json:"avatar_static"` - Header string `json:"header"` - HeaderStatic string `json:"header_static"` - Emojis []Emoji `json:"emojis"` - Moved *Account `json:"moved"` - Fields []Field `json:"fields"` - Bot bool `json:"bot"` - Pleroma AccountPleroma `json:"pleroma"` + ID string `json:"id"` + Username string `json:"username"` + Acct string `json:"acct"` + DisplayName string `json:"display_name"` + Locked bool `json:"locked"` + CreatedAt time.Time `json:"created_at"` + FollowersCount int64 `json:"followers_count"` + FollowingCount int64 `json:"following_count"` + StatusesCount int64 `json:"statuses_count"` + Note string `json:"note"` + URL string `json:"url"` + Avatar string `json:"avatar"` + AvatarStatic string `json:"avatar_static"` + Header string `json:"header"` + HeaderStatic string `json:"header_static"` + Emojis []Emoji `json:"emojis"` + Moved *Account `json:"moved"` + Fields []Field `json:"fields"` + Bot bool `json:"bot"` + Pleroma *AccountPleroma `json:"pleroma"` } // 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 { 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 } diff --git a/service/service.go b/service/service.go index 2504f43..e81e007 100644 --- a/service/service.go +++ b/service/service.go @@ -339,6 +339,7 @@ func (svc *service) ServeThreadPage(ctx context.Context, c *model.Client, for i := range statuses { statuses[i].ShowReplies = true statuses[i].ReplyMap = replies + statuses[i].ReplyNumber = i addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i+1) } diff --git a/templates/status.tmpl b/templates/status.tmpl index 0371a4e..ade9d25 100644 --- a/templates/status.tmpl +++ b/templates/status.tmpl @@ -56,7 +56,7 @@ {{if .InReplyToID}} <div class="status-reply-to"> <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> </div> {{if index .ReplyMap .ID}} <span class="status-reply-info-divider"> - </span> {{end}} |