42wim / matterircd

Connect to your mattermost or slack using your IRC-client of choice.
MIT License
294 stars 60 forks source link

Save last viewed at state and use for replaying logs #361

Closed hloeung closed 3 years ago

hloeung commented 3 years ago

Per https://github.com/42wim/matterircd/issues/245, we can't trust that Mattermost has updated the last viewed for channel. Instead, we save this locally and use that for replaying of logs. Useful for when experiencing flaky network causing matterircd to reconnect.

This is also part of https://github.com/42wim/matterircd/issues/313, we can dump this out to disk and read/load on start up.

With testing on my laptop, suspend, then resume. Adding print logging on line 555 (logger.Info("Using last saved for channel %s ", brchannel.ID, lastViewedAt)):

[0194] ERROR matterclient: connection not alive: NewWebSocketClient: model.websocket_client.connect_fail.app_error, read tcp 192.168.1.23:42334->xxx.xxx.xxx.xxx:443: read: connection reset by peer
[0204] ERROR matterclient: got a listen error: &model.AppError{Id:"model.websocket_client.connect_fail.app_error", Message:"model.websocket_client.connect_fail.app_error", DetailedError:"read tcp 192.168.1.23:42334->xxx.xxx.xxx.xxx:443: read: connection reset by peer", RequestId:"", StatusCode:500, Where:"NewWebSocketClient", IsOAuth:false, params:map[string]interface {}(nil)}
[0204]  INFO matterclient: reconnect: logout
[0204]  INFO matterclient: reconnect: login
[0205]  INFO matterclient: Found version 5.27.0.5.27.0.3bd4fc983a4aa622183c3bd1e77029e0.true
[0211]  INFO matterclient: found xxx users in team myteam
[0213]  INFO matterclient: reconnect successful
INFO[2020-12-13T09:25:21+11:00] Using last saved for channel %symnb5h6ubifuiymzntyumqtgae 1607811527343  module=matterircd

Then again, but with a message waiting:

|09:19 -!- Irssi: Join to #haw-test was synced in 39 secs
|09:46 <matterircd> Replaying since 2020-12-13 09:46:26
|09:46 <hloeung> [09:46] Test replay backlog  [@@zy7t6us9c3fn8yywj3cmp4mb8e]

With no old and repeated replay logs from any of the channels I'm in.

42wim commented 3 years ago

Looking good, nice simple solution 👍 Will try to do some tests myself tomorrow.