forked from orkestral/venom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-chat.js
33 lines (33 loc) · 820 Bytes
/
get-chat.js
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
export async function getChat(id) {
if (!id) {
return false;
}
id = typeof id == 'string' ? id : id._serialized;
let found = Store.Chat.get(id);
if (!found) {
if (Store.CheckWid.validateWid(id)) {
const ConstructChat = new window.Store.UserConstructor(id, {
intentionallyUsePrivateConstructor: !0
});
const chatWid = new Store.WidFactory.createWid(id);
await Store.Chat.add(
{
createdLocally: true,
id: chatWid
},
{
merge: true
}
);
found = Store.Chat.find(ConstructChat) || false;
}
}
if (found) {
found.sendMessage = found.sendMessage
? found.sendMessage
: function () {
return window.Store.sendMessage.apply(this, arguments);
};
}
return found;
}