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:
@@ -195,10 +195,8 @@ func (t *Transferer) WithPhoto(pc tg.PhotoClass) *ReadyTransferer {
|
||||
// given user's photo as the location that will be downloaded by the
|
||||
// [ReadyTransferer].
|
||||
func (t *Transferer) WithUserPhoto(ctx context.Context, store *store.ScopedStore, user *tg.User, photoID int64) (*ReadyTransferer, error) {
|
||||
if accessHash, found, err := store.GetUserAccessHash(ctx, user.GetID()); err != nil {
|
||||
if accessHash, err := store.GetAccessHash(ctx, user.GetID()); err != nil {
|
||||
return nil, fmt.Errorf("failed to get user access hash for %d: %w", user.GetID(), err)
|
||||
} else if !found {
|
||||
return nil, fmt.Errorf("user access hash not found for %d", user.GetID())
|
||||
} else {
|
||||
return &ReadyTransferer{
|
||||
inner: t,
|
||||
|
||||
Reference in New Issue
Block a user