aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2022-01-27 12:05:15 +0000
committerr <r@freesoftwareextremist.com>2022-01-27 12:05:15 +0000
commitb8c0133bcd5e7f1d4063ad992949cc19d18e7aad (patch)
tree5322b83d194c9ffcb498627bdd16175f9508d87d /service
parent54c42455f393c5ae8ebdb19884d40ebd9a18f755 (diff)
parent4ef5e0daf285f41850c9ac53b0322d85fbf5eaec (diff)
downloadbloat-b8c0133bcd5e7f1d4063ad992949cc19d18e7aad.tar.gz
bloat-b8c0133bcd5e7f1d4063ad992949cc19d18e7aad.zip
Merge branch 'master' into absolute_fluoride
Diffstat (limited to 'service')
-rw-r--r--service/service.go19
-rw-r--r--service/transport.go32
2 files changed, 33 insertions, 18 deletions
diff --git a/service/service.go b/service/service.go
index a846322..c56114c 100644
--- a/service/service.go
+++ b/service/service.go
@@ -114,7 +114,8 @@ func (s *service) ErrorPage(c *client, err error, retry bool) error {
var sessionErr bool
if err != nil {
errStr = err.Error()
- if err == errInvalidSession || err == errInvalidCSRFToken {
+ if me, ok := err.(mastodon.Error); ok && me.IsAuthError() ||
+ err == errInvalidSession || err == errInvalidCSRFToken {
sessionErr = true
}
}
@@ -417,18 +418,24 @@ func (s *service) NotificationPage(c *client, maxID string,
var nextLink string
var unreadCount int
var readID string
- var excludes []string
+ var includes, excludes []string
var pg = mastodon.Pagination{
MaxID: maxID,
MinID: minID,
Limit: 20,
}
+ if c.s.Settings.HideUnsupportedNotifs {
+ // Explicitly include the supported types.
+ // For now, only Pleroma supports this option, Mastadon
+ // will simply ignore the unknown params.
+ includes = []string{"follow", "follow_request", "mention", "reblog", "favourite"}
+ }
if c.s.Settings.AntiDopamineMode {
- excludes = []string{"follow", "favourite", "reblog"}
+ excludes = append(excludes, "follow", "favourite", "reblog")
}
- notifications, err := c.GetNotifications(c.ctx, &pg, excludes)
+ notifications, err := c.GetNotifications(c.ctx, &pg, includes, excludes)
if err != nil {
return
}
@@ -914,8 +921,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 a022b02..02e6106 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -415,7 +415,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
}
@@ -484,20 +490,22 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
fluorideMode := c.r.FormValue("fluoride_mode") == "true"
darkMode := c.r.FormValue("dark_mode") == "true"
antiDopamineMode := c.r.FormValue("anti_dopamine_mode") == "true"
+ hideUnsupportedNotifs := c.r.FormValue("hide_unsupported_notifs") == "true"
css := c.r.FormValue("css")
settings := &model.Settings{
- DefaultVisibility: visibility,
- DefaultFormat: format,
- CopyScope: copyScope,
- ThreadInNewTab: threadInNewTab,
- HideAttachments: hideAttachments,
- MaskNSFW: maskNSFW,
- NotificationInterval: ni,
- FluorideMode: fluorideMode,
- DarkMode: darkMode,
- AntiDopamineMode: antiDopamineMode,
- CSS: css,
+ DefaultVisibility: visibility,
+ DefaultFormat: format,
+ CopyScope: copyScope,
+ ThreadInNewTab: threadInNewTab,
+ HideAttachments: hideAttachments,
+ MaskNSFW: maskNSFW,
+ NotificationInterval: ni,
+ FluorideMode: fluorideMode,
+ DarkMode: darkMode,
+ AntiDopamineMode: antiDopamineMode,
+ HideUnsupportedNotifs: hideUnsupportedNotifs,
+ CSS: css,
}
err := s.SaveSettings(c, settings)