Add "mute (keep notifications)" button

This commit is contained in:
r 2021-10-29 14:20:15 +00:00
parent 7d389d2258
commit 4d68062f2d
4 changed files with 21 additions and 5 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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}}
-