diff options
author | Kegsay <kegan@matrix.org> | 2020-07-03 17:24:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 17:24:51 +0100 |
commit | ea9df46c70a1b806c11198a1272aac99dc8b62f4 (patch) | |
tree | a2851f4702bbd58dd8fc9c3ba614bd8a61a8a227 /roomserver/api | |
parent | 46dbc46f84a7120bb418ec48ddc1d6248ef97979 (diff) |
Implement local redaction (#1182)
* Create redaction events and apply checks (but do not send them)
* Send redactions to the roomserver
* Linting
* Slightly better wording
Diffstat (limited to 'roomserver/api')
-rw-r--r-- | roomserver/api/wrapper.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/roomserver/api/wrapper.go b/roomserver/api/wrapper.go index b73cd190..b6a4c888 100644 --- a/roomserver/api/wrapper.go +++ b/roomserver/api/wrapper.go @@ -18,6 +18,7 @@ import ( "context" "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/util" ) // SendEvents to the roomserver The events are written with KindNew. @@ -115,3 +116,19 @@ func SendInvite( } return nil } + +// GetEvent returns the event or nil, even on errors. +func GetEvent(ctx context.Context, rsAPI RoomserverInternalAPI, eventID string) *gomatrixserverlib.HeaderedEvent { + var res QueryEventsByIDResponse + err := rsAPI.QueryEventsByID(ctx, &QueryEventsByIDRequest{ + EventIDs: []string{eventID}, + }, &res) + if err != nil { + util.GetLogger(ctx).WithError(err).Error("Failed to QueryEventsByID") + return nil + } + if len(res.Events) != 1 { + return nil + } + return &res.Events[0] +} |