store: refactor access hash and session tables
* Move sessions to user_login metadata, as that data rarely changes after login. * Merge user and channel access hashes. Those IDs don't conflict. * Split usernames into a new table to allow better `ON CONFLICT` updates (when a username moves to another entity, we want the old row to be replaced). Usernames also don't need to be scoped to a login.
This commit is contained in:
@@ -457,13 +457,9 @@ func (t *TelegramClient) HandleMatrixReadReceipt(ctx context.Context, msg *bridg
|
||||
})
|
||||
case ids.PeerTypeChannel:
|
||||
var accessHash int64
|
||||
var found bool
|
||||
accessHash, found, readMessagesErr = t.ScopedStore.GetChannelAccessHash(ctx, t.telegramUserID, id)
|
||||
accessHash, readMessagesErr = t.ScopedStore.GetAccessHash(ctx, id)
|
||||
if readMessagesErr != nil {
|
||||
return
|
||||
} else if !found {
|
||||
readMessagesErr = fmt.Errorf("channel access hash not found for %d", id)
|
||||
return
|
||||
}
|
||||
_, readMessagesErr = t.client.API().ChannelsReadHistory(ctx, &tg.ChannelsReadHistoryRequest{
|
||||
Channel: &tg.InputChannel{ChannelID: id, AccessHash: accessHash},
|
||||
|
||||
Reference in New Issue
Block a user