-
Notifications
You must be signed in to change notification settings - Fork 347
/
dialog.getDialogsByIdList_handler.go
68 lines (62 loc) · 1.68 KB
/
dialog.getDialogsByIdList_handler.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
66
67
68
/*
* Created from 'scheme.tl' by 'mtprotoc'
*
* Copyright (c) 2021-present, Teamgram Studio (https://teamgram.io).
* All rights reserved.
*
* Author: teamgramio (teamgram.io@gmail.com)
*/
package core
import (
"github.com/teamgram/proto/mtproto"
"github.com/teamgram/teamgram-server/app/service/biz/dialog/dialog"
"github.com/teamgram/teamgram-server/app/service/biz/dialog/internal/dal/dataobject"
)
// DialogGetDialogsByIdList
// dialog.getDialogsByIdList user_id:long id_list:Vector<long> = Vector<DialogExt>;
func (c *DialogCore) DialogGetDialogsByIdList(in *dialog.TLDialogGetDialogsByIdList) (*dialog.Vector_DialogExt, error) {
var (
dList dialog.DialogExtList
meId = in.GetUserId()
// peerId := mtproto.MakePeerDialogId()
)
doList, _ := c.svcCtx.Dao.DialogsDAO.SelectPeerDialogList(
c.ctx,
meId,
in.IdList)
for _, id := range in.IdList {
found := false
for i := 0; i < len(doList); i++ {
if doList[i].PeerDialogId == id {
found = true
dList = append(dList, makeDialog(&doList[i]))
break
}
}
if !found {
peerType, peerId := mtproto.GetPeerUtilByPeerDialogId(id)
dList = append(dList, makeDialog(&dataobject.DialogsDO{
UserId: in.UserId,
PeerType: peerType,
PeerId: peerId,
PeerDialogId: id,
Pinned: 0,
TopMessage: 0,
PinnedMsgId: 0,
ReadInboxMaxId: 0,
ReadOutboxMaxId: 0,
UnreadCount: 0,
UnreadMark: false,
DraftType: 0,
DraftMessageData: "null",
FolderId: 0,
FolderPinned: 0,
HasScheduled: false,
Date2: 0,
}))
}
}
return &dialog.Vector_DialogExt{
Datas: dList,
}, nil
}