7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
49 lines
982 B
Go
49 lines
982 B
Go
package e2e
|
|
|
|
import "go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
|
|
|
type messageDatabase struct {
|
|
common []tg.MessageClass
|
|
secret []tg.EncryptedMessageClass
|
|
channels map[int64][]tg.MessageClass
|
|
}
|
|
|
|
type peerDatabase struct {
|
|
users map[int64]*tg.User
|
|
chats map[int64]*tg.Chat
|
|
channels map[int64]*tg.Channel
|
|
|
|
id int64
|
|
}
|
|
|
|
func (p *peerDatabase) createUser(username string) *tg.PeerUser {
|
|
p.users[p.id] = &tg.User{
|
|
ID: p.id,
|
|
Username: username,
|
|
}
|
|
|
|
defer func() { p.id++ }()
|
|
return &tg.PeerUser{UserID: p.id}
|
|
}
|
|
|
|
func (p *peerDatabase) createChat(title string) *tg.PeerChat {
|
|
p.chats[p.id] = &tg.Chat{
|
|
ID: p.id,
|
|
Title: title,
|
|
}
|
|
|
|
defer func() { p.id++ }()
|
|
return &tg.PeerChat{ChatID: p.id}
|
|
}
|
|
|
|
func (p *peerDatabase) createChannel(username string) *tg.PeerChannel {
|
|
p.channels[p.id] = &tg.Channel{
|
|
ID: p.id,
|
|
Username: username,
|
|
}
|
|
p.channels[p.id].SetAccessHash(p.id * 2)
|
|
|
|
defer func() { p.id++ }()
|
|
return &tg.PeerChannel{ChannelID: p.id}
|
|
}
|