-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
file_id.go
65 lines (57 loc) · 1.63 KB
/
file_id.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package botapi
import (
"github.com/gotd/td/constant"
"github.com/gotd/td/fileid"
"github.com/gotd/td/tg"
"github.com/gotd/botapi/internal/oas"
)
func (b *BotAPI) encodeFileID(f fileid.FileID) (fileID, fileUniqueID string) {
fileID, _ = fileid.EncodeFileID(f)
// TODO(tdakkota): generate unique id
fileUniqueID = "todo"
return fileID, fileUniqueID
}
func (b *BotAPI) profilePhotoFileID(
id constant.TDLibPeerID,
accessHash int64,
photo fileid.ChatPhoto,
big bool,
) (fileID, fileUniqueID string) {
return b.encodeFileID(fileid.FromChatPhoto(id, accessHash, photo, big))
}
func (b *BotAPI) setChatPhoto(
id constant.TDLibPeerID,
accessHash int64,
from tg.ChatPhotoClass,
) (to oas.OptChatPhoto) {
p, ok := from.(*tg.ChatPhoto)
if !ok {
return
}
smallFileID, smallUniqueFileID := b.profilePhotoFileID(id, accessHash, p, false)
bigFileID, bigUniqueFileID := b.profilePhotoFileID(id, accessHash, p, true)
return oas.NewOptChatPhoto(oas.ChatPhoto{
SmallFileID: smallFileID,
SmallFileUniqueID: smallUniqueFileID,
BigFileID: bigFileID,
BigFileUniqueID: bigUniqueFileID,
})
}
func (b *BotAPI) setUserPhoto(
id constant.TDLibPeerID,
accessHash int64,
from tg.UserProfilePhotoClass,
) (to oas.OptChatPhoto) {
p, ok := from.(*tg.UserProfilePhoto)
if !ok {
return
}
smallFileID, smallUniqueFileID := b.profilePhotoFileID(id, accessHash, p, false)
bigFileID, bigUniqueFileID := b.profilePhotoFileID(id, accessHash, p, true)
return oas.NewOptChatPhoto(oas.ChatPhoto{
SmallFileID: smallFileID,
SmallFileUniqueID: smallUniqueFileID,
BigFileID: bigFileID,
BigFileUniqueID: bigUniqueFileID,
})
}