diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-21 19:28:00 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-21 19:28:00 +0100 |
commit | b0644c3a17dfd1a55f4ed5f4f91fcc84e74359ed (patch) | |
tree | 9a0e45bde1ad4b30e116ab58c6db1241f5e1c9df /appservice | |
parent | e1b838d30493effbcd8a23fe43e2b131c745b722 (diff) | |
download | easybridge-b0644c3a17dfd1a55f4ed5f4f91fcc84e74359ed.tar.gz easybridge-b0644c3a17dfd1a55f4ed5f4f91fcc84e74359ed.zip |
Basic backlogging
Diffstat (limited to 'appservice')
-rw-r--r-- | appservice/account.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/appservice/account.go b/appservice/account.go index 3791ee3..e2f2ee9 100644 --- a/appservice/account.go +++ b/appservice/account.go @@ -230,7 +230,7 @@ func (a *Account) eventInternal(event *Event) error { err = mx.RoomInvite(mx_room_id, mx_user_id) if err != nil { if strings.Contains(err.Error(), "already in the room") { - err = nil + return nil } return err } @@ -260,6 +260,16 @@ func (a *Account) eventInternal(event *Event) error { } } + if event.Id != "" { + cache_key := fmt.Sprintf("%s/event_seen/%s/%s", + a.Protocol, mx_room_id, event.Id) + if !dbCacheTestAndSet(cache_key, "yes") { + // false: cache key was not modified, meaning we + // already saw the event + return nil + } + } + typ := "m.text" if event.Type == EVENT_ACTION { typ = "m.emote" |