aboutsummaryrefslogtreecommitdiff
path: root/clientapi
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 /clientapi
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 'clientapi')
-rw-r--r--clientapi/producers/syncapi.go9
-rw-r--r--clientapi/routing/account_data.go11
-rw-r--r--clientapi/routing/room_tagging.go4
3 files changed, 16 insertions, 8 deletions
diff --git a/clientapi/producers/syncapi.go b/clientapi/producers/syncapi.go
index 6e869c31..187e3412 100644
--- a/clientapi/producers/syncapi.go
+++ b/clientapi/producers/syncapi.go
@@ -42,7 +42,7 @@ type SyncAPIProducer struct {
}
// SendData sends account data to the sync API server
-func (p *SyncAPIProducer) SendData(userID string, roomID string, dataType string, readMarker *eventutil.ReadMarkerJSON) error {
+func (p *SyncAPIProducer) SendData(userID string, roomID string, dataType string, readMarker *eventutil.ReadMarkerJSON, ignoredUsers *types.IgnoredUsers) error {
m := &nats.Msg{
Subject: p.TopicClientData,
Header: nats.Header{},
@@ -50,9 +50,10 @@ func (p *SyncAPIProducer) SendData(userID string, roomID string, dataType string
m.Header.Set(jetstream.UserID, userID)
data := eventutil.AccountData{
- RoomID: roomID,
- Type: dataType,
- ReadMarker: readMarker,
+ RoomID: roomID,
+ Type: dataType,
+ ReadMarker: readMarker,
+ IgnoredUsers: ignoredUsers,
}
var err error
m.Data, err = json.Marshal(data)
diff --git a/clientapi/routing/account_data.go b/clientapi/routing/account_data.go
index 873ffaf5..9399fd0b 100644
--- a/clientapi/routing/account_data.go
+++ b/clientapi/routing/account_data.go
@@ -25,6 +25,7 @@ import (
"github.com/matrix-org/dendrite/clientapi/producers"
"github.com/matrix-org/dendrite/internal/eventutil"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
+ "github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/util"
@@ -126,8 +127,14 @@ func SaveAccountData(
return util.ErrorResponse(err)
}
+ var ignoredUsers *types.IgnoredUsers
+ if dataType == "m.ignored_user_list" {
+ ignoredUsers = &types.IgnoredUsers{}
+ _ = json.Unmarshal(body, ignoredUsers)
+ }
+
// TODO: user API should do this since it's account data
- if err := syncProducer.SendData(userID, roomID, dataType, nil); err != nil {
+ if err := syncProducer.SendData(userID, roomID, dataType, nil, ignoredUsers); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("syncProducer.SendData failed")
return jsonerror.InternalServerError()
}
@@ -184,7 +191,7 @@ func SaveReadMarker(
return util.ErrorResponse(err)
}
- if err := syncProducer.SendData(device.UserID, roomID, "m.fully_read", &r); err != nil {
+ if err := syncProducer.SendData(device.UserID, roomID, "m.fully_read", &r, nil); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("syncProducer.SendData failed")
return jsonerror.InternalServerError()
}
diff --git a/clientapi/routing/room_tagging.go b/clientapi/routing/room_tagging.go
index 83294b18..ce173613 100644
--- a/clientapi/routing/room_tagging.go
+++ b/clientapi/routing/room_tagging.go
@@ -98,7 +98,7 @@ func PutTag(
return jsonerror.InternalServerError()
}
- if err = syncProducer.SendData(userID, roomID, "m.tag", nil); err != nil {
+ if err = syncProducer.SendData(userID, roomID, "m.tag", nil, nil); err != nil {
logrus.WithError(err).Error("Failed to send m.tag account data update to syncapi")
}
@@ -151,7 +151,7 @@ func DeleteTag(
}
// TODO: user API should do this since it's account data
- if err := syncProducer.SendData(userID, roomID, "m.tag", nil); err != nil {
+ if err := syncProducer.SendData(userID, roomID, "m.tag", nil, nil); err != nil {
logrus.WithError(err).Error("Failed to send m.tag account data update to syncapi")
}