aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2021-10-29 14:20:15 +0000
committerr <r@freesoftwareextremist.com>2021-10-29 14:20:15 +0000
commit4d68062f2d0525a9d2a40e50d60ea9b25daae9ad (patch)
treef6a8fd244a81dc1f9632aa04b5285118e2aa7191
parent7d389d22581cc785005a42d655eb7f9c32aac3ec (diff)
downloadbloat-4d68062f2d0525a9d2a40e50d60ea9b25daae9ad.tar.gz
bloat-4d68062f2d0525a9d2a40e50d60ea9b25daae9ad.zip
Add "mute (keep notifications)" button
-rw-r--r--mastodon/accounts.go8
-rw-r--r--service/service.go4
-rw-r--r--service/transport.go8
-rw-r--r--templates/user.tmpl6
4 files changed, 21 insertions, 5 deletions
diff --git a/mastodon/accounts.go b/mastodon/accounts.go
index 694e672..df0a3b7 100644
--- a/mastodon/accounts.go
+++ b/mastodon/accounts.go
@@ -243,9 +243,13 @@ func (c *Client) AccountUnblock(ctx context.Context, id string) (*Relationship,
}
// AccountMute mute the account.
-func (c *Client) AccountMute(ctx context.Context, id string) (*Relationship, error) {
+func (c *Client) AccountMute(ctx context.Context, id string, notifications *bool) (*Relationship, error) {
+ params := url.Values{}
+ if notifications != nil {
+ params.Set("notifications", strconv.FormatBool(*notifications))
+ }
var relationship Relationship
- err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/mute", url.PathEscape(string(id))), nil, &relationship, nil)
+ err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/mute", url.PathEscape(string(id))), params, &relationship, nil)
if err != nil {
return nil, err
}
diff --git a/service/service.go b/service/service.go
index 244fd81..7122666 100644
--- a/service/service.go
+++ b/service/service.go
@@ -907,8 +907,8 @@ func (s *service) Reject(c *client, id string) (err error) {
return c.FollowRequestReject(c.ctx, id)
}
-func (s *service) Mute(c *client, id string) (err error) {
- _, err = c.AccountMute(c.ctx, id)
+func (s *service) Mute(c *client, id string, notifications *bool) (err error) {
+ _, err = c.AccountMute(c.ctx, id, notifications)
return
}
diff --git a/service/transport.go b/service/transport.go
index 42b371a..a7912e6 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -406,7 +406,13 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
mute := handle(func(c *client) error {
id, _ := mux.Vars(c.r)["id"]
- err := s.Mute(c, id)
+ q := c.r.URL.Query()
+ var notifications *bool
+ if r, ok := q["notifications"]; ok && len(r) > 0 {
+ notifications = new(bool)
+ *notifications = r[0] == "true"
+ }
+ err := s.Mute(c, id, notifications)
if err != nil {
return err
}
diff --git a/templates/user.tmpl b/templates/user.tmpl
index c7b3164..32b5681 100644
--- a/templates/user.tmpl
+++ b/templates/user.tmpl
@@ -83,6 +83,12 @@
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
<input type="submit" value="mute" class="btn-link">
</form>
+ -
+ <form class="d-inline" action="/mute/{{.User.ID}}?notifications=false" method="post">
+ <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
+ <input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
+ <input type="submit" value="mute (keep notifications)" class="btn-link">
+ </form>
{{end}}
{{if .User.Pleroma.Relationship.Following}}
-