diff --git a/mastodon/status.go b/mastodon/status.go index 863c9b2..1bdb3e9 100644 --- a/mastodon/status.go +++ b/mastodon/status.go @@ -200,9 +200,11 @@ func (c *Client) UnReaction(ctx context.Context, id string, emoji string) (*Stat } // Reblog is reblog the toot of id and return status of reblog. -func (c *Client) Reblog(ctx context.Context, id string) (*Status, error) { +func (c *Client) Reblog(ctx context.Context, id string, visibility string) (*Status, error) { var status Status - err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/reblog", id), nil, &status, nil) + params := url.Values{} + params.Set("visibility", visibility) + err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/reblog", id), params, &status, nil) if err != nil { return nil, err } diff --git a/service/service.go b/service/service.go index 550d49d..4343928 100644 --- a/service/service.go +++ b/service/service.go @@ -1052,8 +1052,8 @@ func (s *service) UnReact(c *client, id string, emoji string) (count int64, err return } -func (s *service) Retweet(c *client, id string) (count int64, err error) { - st, err := c.Reblog(c.ctx, id) +func (s *service) Retweet(c *client, id string, visibility string) (count int64, err error) { + st, err := c.Reblog(c.ctx, id, visibility) if err != nil { return } diff --git a/service/transport.go b/service/transport.go index 6b20559..6b9250c 100644 --- a/service/transport.go +++ b/service/transport.go @@ -381,7 +381,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler { retweet := handle(func(c *client) error { id, _ := mux.Vars(c.r)["id"] rid := c.r.FormValue("retweeted_by_id") - _, err := s.Retweet(c, id) + visibility := c.r.FormValue("retweet_visibility") + _, err := s.Retweet(c, id, visibility) if err != nil { return err } @@ -773,7 +774,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler { fRetweet := handle(func(c *client) error { id, _ := mux.Vars(c.r)["id"] - count, err := s.Retweet(c, id) + visibility := c.r.FormValue("retweet_visibility") + count, err := s.Retweet(c, id, visibility) if err != nil { return err } diff --git a/static/fluoride.js b/static/fluoride.js index e6a63ef..62ce0a4 100644 --- a/static/fluoride.js +++ b/static/fluoride.js @@ -9,6 +9,7 @@ var reverseActions = { var csrfToken = ""; var antiDopamineMode = false; +var retweetVisibility = "public" function checkCSRFToken() { var tag = document.querySelector("meta[name='csrf_token']"); @@ -22,6 +23,12 @@ function checkAntiDopamineMode() { antiDopamineMode = tag.getAttribute("content") === "true"; } +function checkRetweetVisibility() { + var tag = document.querySelector("meta[name='retweet_visibility']"); + if (tag) + retweetVisibility = tag.getAttribute("content"); +} + function http(method, url, body, type, success, error) { var req = new XMLHttpRequest(); req.onload = function() { @@ -97,7 +104,7 @@ function handleRetweetForm(id, f) { updateActionForm(id, forms[i], reverseActions[action]); } - var body = "csrf_token=" + encodeURIComponent(csrfToken); + var body = "csrf_token=" + encodeURIComponent(csrfToken) + "&retweet_visibility=" + encodeURIComponent(retweetVisibility); var contentType = "application/x-www-form-urlencoded"; http("POST", "/fluoride/" + action + "/" + id, body, contentType, function(res, type) { @@ -288,6 +295,7 @@ function onPaste(e) { document.addEventListener("DOMContentLoaded", function() { checkCSRFToken(); checkAntiDopamineMode(); + checkRetweetVisibility(); var statuses = document.querySelectorAll(".status-container"); for (var i = 0; i < statuses.length; i++) { diff --git a/templates/status.tmpl b/templates/status.tmpl index 9378aba..18d0730 100644 --- a/templates/status.tmpl +++ b/templates/status.tmpl @@ -225,11 +225,27 @@
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
+ - + + +
+ {{if or (eq .Visibility "private") (eq .Visibility "direct")}} + Locked + {{else}} + + + + + + + {{end}} +
+
{{if and (not $.Ctx.AntiDopamineMode) .ReblogsCount}} ({{DisplayInteractionCount .ReblogsCount}})