42wim / matterircd

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

Fix incorrect msg/thread counters #542

Closed hloeung closed 1 year ago

hloeung commented 1 year ago

When using mattericd's default threading, the msgMap is populated with message/thread IDs and never removed. This means that when we cycle past 4k, we can have entries with duplicate counters causing issues where replies could end up to an incorrect thread.

This fixes it by introducing an index with the counter and to which message/thread ID. When index entries are updated and the thread no longer referenced, the entries in the msgMap are removed.

This also ensures that msgMap remains a constant bounded size.

It should be noted that this also relies on https://github.com/42wim/matterircd/pull/544, in particular https://github.com/42wim/matterircd/blob/master/mm-go-irckit/server_commands.go#L665