diff options
author | r <r@freesoftwareextremist.com> | 2021-09-05 17:17:59 +0000 |
---|---|---|
committer | r <r@freesoftwareextremist.com> | 2021-09-05 17:33:58 +0000 |
commit | 54c42455f393c5ae8ebdb19884d40ebd9a18f755 (patch) | |
tree | deecf729e7ba3565058dca6678e2b78805206097 /service/service.go | |
parent | 4351155f67963b58feeba0d16bb998862ceb4d69 (diff) | |
download | bloat-54c42455f393c5ae8ebdb19884d40ebd9a18f755.tar.gz bloat-54c42455f393c5ae8ebdb19884d40ebd9a18f755.zip |
Add quick reply
Diffstat (limited to 'service/service.go')
-rw-r--r-- | service/service.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/service/service.go b/service/service.go index c098c76..a846322 100644 --- a/service/service.go +++ b/service/service.go @@ -321,6 +321,62 @@ func (s *service) ThreadPage(c *client, id string, reply bool) (err error) { return s.renderer.Render(c.rctx, c.w, renderer.ThreadPage, data) } +func (s *service) QuickReplyPage(c *client, id string) (err error) { + status, err := c.GetStatus(c.ctx, id) + if err != nil { + return + } + + var ancestor *mastodon.Status + if status.InReplyToID != nil { + ancestor, err = c.GetStatus(c.ctx, status.InReplyToID.(string)) + if err != nil { + return + } + } + + var content string + if c.s.UserID != status.Account.ID { + content += "@" + status.Account.Acct + " " + } + for i := range status.Mentions { + if status.Mentions[i].ID != c.s.UserID && + status.Mentions[i].ID != status.Account.ID { + content += "@" + status.Mentions[i].Acct + " " + } + } + + var visibility string + isDirect := status.Visibility == "direct" + if isDirect || c.s.Settings.CopyScope { + visibility = status.Visibility + } else { + visibility = c.s.Settings.DefaultVisibility + } + + pctx := model.PostContext{ + DefaultVisibility: visibility, + DefaultFormat: c.s.Settings.DefaultFormat, + Formats: s.postFormats, + ReplyContext: &model.ReplyContext{ + InReplyToID: id, + InReplyToName: status.Account.Acct, + QuickReply: true, + ReplyContent: content, + ForceVisibility: isDirect, + }, + } + + cdata := s.cdata(c, "post by "+status.Account.DisplayName, 0, 0, "") + data := &renderer.QuickReplyData{ + Ancestor: ancestor, + Status: status, + PostContext: pctx, + CommonData: cdata, + } + return s.renderer.Render(c.rctx, c.w, renderer.QuickReplyPage, data) +} + func (svc *service) StatusPopup(c *client, id string) (err error) { status, err := c.GetStatus(c.ctx, id) if err != nil { |