mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-14 00:39:22 +02:00
Add "mute (keep notifications)" button
This commit is contained in:
parent
7d389d2258
commit
4d68062f2d
|
@ -243,9 +243,13 @@ func (c *Client) AccountUnblock(ctx context.Context, id string) (*Relationship,
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountMute mute the account.
|
// 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
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -907,8 +907,8 @@ func (s *service) Reject(c *client, id string) (err error) {
|
||||||
return c.FollowRequestReject(c.ctx, id)
|
return c.FollowRequestReject(c.ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) Mute(c *client, id string) (err error) {
|
func (s *service) Mute(c *client, id string, notifications *bool) (err error) {
|
||||||
_, err = c.AccountMute(c.ctx, id)
|
_, err = c.AccountMute(c.ctx, id, notifications)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,7 +406,13 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
||||||
|
|
||||||
mute := handle(func(c *client) error {
|
mute := handle(func(c *client) error {
|
||||||
id, _ := mux.Vars(c.r)["id"]
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,12 @@
|
||||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="mute" class="btn-link">
|
<input type="submit" value="mute" class="btn-link">
|
||||||
</form>
|
</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}}
|
{{end}}
|
||||||
{{if .User.Pleroma.Relationship.Following}}
|
{{if .User.Pleroma.Relationship.Following}}
|
||||||
-
|
-
|
||||||
|
|
Loading…
Reference in New Issue