aboutsummaryrefslogtreecommitdiff
path: root/userapi/consumers
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-04-07 16:08:19 +0200
committerGitHub <noreply@github.com>2022-04-07 15:08:19 +0100
commit60ee7eef4c8ea7e17135d52d3dde9be0b54e2f55 (patch)
tree5e0330d4fbdac2f67e67338c445c4d8a3b0b68ae /userapi/consumers
parent99ef5472959a4e4d49bd9760fcb8b3872e21fa71 (diff)
Add possibility to ignore users (#2329)
* Add ignore users * Ignore users in pushrules Add passing tests * Update sytest lists * Store ignore knowledge in the sync API * Fix copyrights Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'userapi/consumers')
-rw-r--r--userapi/consumers/syncapi_streamevent.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/userapi/consumers/syncapi_streamevent.go b/userapi/consumers/syncapi_streamevent.go
index 34a67d2e..9ef7b508 100644
--- a/userapi/consumers/syncapi_streamevent.go
+++ b/userapi/consumers/syncapi_streamevent.go
@@ -404,8 +404,24 @@ func (s *OutputStreamEventConsumer) evaluatePushRules(ctx context.Context, event
return nil, nil
}
+ // Get accountdata to check if the event.Sender() is ignored by mem.LocalPart
+ data, err := s.db.GetAccountDataByType(ctx, mem.Localpart, "", "m.ignored_user_list")
+ if err != nil {
+ return nil, err
+ }
+ if data != nil {
+ ignored := types.IgnoredUsers{}
+ err = json.Unmarshal(data, &ignored)
+ if err != nil {
+ return nil, err
+ }
+ sender := event.Sender()
+ if _, ok := ignored.List[sender]; ok {
+ return nil, fmt.Errorf("user %s is ignored", sender)
+ }
+ }
var res api.QueryPushRulesResponse
- if err := s.userAPI.QueryPushRules(ctx, &api.QueryPushRulesRequest{UserID: mem.UserID}, &res); err != nil {
+ if err = s.userAPI.QueryPushRules(ctx, &api.QueryPushRulesRequest{UserID: mem.UserID}, &res); err != nil {
return nil, err
}