This commit is contained in:
sairajzero 2020-12-09 03:59:46 +05:30
parent 7bfc1d1842
commit e12711bb3a

View File

@ -9628,15 +9628,18 @@ Bitcoin.Util = {
else if (evt.data.startsWith(floID, 1)) else if (evt.data.startsWith(floID, 1))
var i = 36 var i = 36
else return; else return;
let d = e = null;
try { try {
let data = JSON.parse(evt.data.substring(i)) let data = JSON.parse(evt.data.substring(i))
let filter = {} let filter = {}
for (let v in data) for (let v in data)
if (checkFilter(v, data[v], request)) if (checkFilter(v, data[v], request))
filter[v] = data[v] filter[v] = data[v]
callback(filter, null) d = filter
} catch (error) { } catch (error) {
callback(null, evt.data.substring(i)) e = evt.data.substring(i)
} finally {
callback(d, e)
} }
} }
this.liveRequest[randID] = node; this.liveRequest[randID] = node;
@ -10838,8 +10841,8 @@ Bitcoin.Util = {
} }
let infoChange = false; let infoChange = false;
for (let vc in dataSet) { for (let vc in dataSet) {
if(groupID !== dataSet[vc].receiverID || if (groupID !== dataSet[vc].receiverID ||
!floGlobals.groups[groupID].members.includes(dataSet[vc].senderID)) !floGlobals.groups[groupID].members.includes(dataSet[vc].senderID))
continue; continue;
try { try {
let data = { let data = {
@ -10848,10 +10851,10 @@ Bitcoin.Util = {
groupID: dataSet[vc].receiverID groupID: dataSet[vc].receiverID
} }
let k = floGlobals.groups[groupID].eKey; let k = floGlobals.groups[groupID].eKey;
if(floGlobals.expiredKeys[groupID]){ if (floGlobals.expiredKeys[groupID]) {
var ex = Object.keys(floGlobals.expiredKeys[groupID]).sort() var ex = Object.keys(floGlobals.expiredKeys[groupID]).sort()
while(ex.lenght && vc > ex[0]) ex.shift() while (ex.lenght && vc > ex[0]) ex.shift()
if(ex.length) if (ex.length)
k = floGlobals.expiredKeys[groupID][ex.shift()] k = floGlobals.expiredKeys[groupID][ex.shift()]
} }
dataSet[vc].message = messenger.util.decrypt(dataSet[vc].message, k) dataSet[vc].message = messenger.util.decrypt(dataSet[vc].message, k)
@ -10890,8 +10893,8 @@ Bitcoin.Util = {
data.message = messenger.util.decrypt(data.message); data.message = messenger.util.decrypt(data.message);
newInbox.messages[vc] = data; newInbox.messages[vc] = data;
messenger.addMark(data.groupID, "unread") messenger.addMark(data.groupID, "unread")
if (!floGlobals.appendix[`lastReceived_${groupID}`] || if (!floGlobals.appendix[`lastReceived_${groupID}`] ||
floGlobals.appendix[`lastReceived_${groupID}`] < vc) floGlobals.appendix[`lastReceived_${groupID}`] < vc)
floGlobals.appendix[`lastReceived_${groupID}`] = vc; floGlobals.appendix[`lastReceived_${groupID}`] = vc;
} catch (error) { } catch (error) {
console.log(error) console.log(error)
@ -10901,20 +10904,20 @@ Bitcoin.Util = {
`lastReceived_${groupID}`); `lastReceived_${groupID}`);
if (infoChange) if (infoChange)
compactIDB.writeData("groupInfo", floGlobals.groups[groupID], groupID) compactIDB.writeData("groupInfo", floGlobals.groups[groupID], groupID)
this.UIcallback["group"](newInbox) messenger.util.UIcallback["group"](newInbox)
} }
return floCloudAPI.requestApplicationData(null, { return floCloudAPI.requestApplicationData(null, {
receiverID: groupID, receiverID: groupID,
lowerVectorClock: floGlobals.appendix[`lastReceived_${groupID}`] + 1, lowerVectorClock: floGlobals.appendix[`lastReceived_${groupID}`] + 1,
callback: callbackFn callback: callbackFn
}) })
} }
}, },
setUIcallbacks(directUI = null, groupUI = null){ setUIcallbacks(directUI = null, groupUI = null) {
if(direct instanceof Function) if (directUI instanceof Function)
this.util.UIcallback["direct"] = directUI this.util.UIcallback["direct"] = directUI
if(groupUI instanceof Function) if (groupUI instanceof Function)
this.util.UIcallback["group"] = groupUI this.util.UIcallback["group"] = groupUI
}, },
@ -11094,7 +11097,7 @@ Bitcoin.Util = {
let r = JSON.parse(dataSet[vc].message); let r = JSON.parse(dataSet[vc].message);
let groupInfo = floGlobals.groups[r.groupID] let groupInfo = floGlobals.groups[r.groupID]
if (dataSet[vc].senderID === groupInfo.admin) { if (dataSet[vc].senderID === groupInfo.admin) {
if(typeof floGlobals.expiredKeys[r.groupID] !== "object") if (typeof floGlobals.expiredKeys[r.groupID] !== "object")
floGlobals.expiredKeys[r.groupID] = {} floGlobals.expiredKeys[r.groupID] = {}
floGlobals.expiredKeys[r.groupID][vc] = groupInfo.eKey floGlobals.expiredKeys[r.groupID][vc] = groupInfo.eKey
groupInfo.eKey = r.newKey; groupInfo.eKey = r.newKey;
@ -11110,7 +11113,7 @@ Bitcoin.Util = {
} }
} }
compactIDB.writeData("appendix", floGlobals.appendix.lastReceived, "lastReceived"); compactIDB.writeData("appendix", floGlobals.appendix.lastReceived, "lastReceived");
this.util.UIcallback["direct"](newInbox) messenger.util.UIcallback["direct"](newInbox)
} }
var options = { var options = {
@ -11448,28 +11451,27 @@ Bitcoin.Util = {
.then(r => res([g, r])) .then(r => res([g, r]))
.catch(e => rej([g, e])) .catch(e => rej([g, e]))
}) })
for (let g in floGlobals.groups) for (let g in floGlobals.groups)
if (floGlobals.groups[g].status !== false) if (floGlobals.groups[g].status !== false)
promises.push(reqFn(g)) promises.push(reqFn(g))
Promise.allSettled(promises).then(result => { Promise.allSettled(promises).then(result => {
let ret = {}; let ret = {};
result.forEach(r => { result.forEach(r => {
if(r.status === 'fulfilled') if (r.status === 'fulfilled')
ret[r.value[0]] = { ret[r.value[0]] = {
status = r.status, status: r.status,
value = r.value[1] value: r.value[1]
} }
else if(r.status === "rejected") else if (r.status === "rejected")
ret[r.reason[0]] = { ret[r.reason[0]] = {
status = r.status, status: r.status,
reason = r.reason[1] reason: r.reason[1]
} }
}) })
resolve(ret) resolve(ret)
}) })
}) })
} }
} }
</script> </script>
</body> </body>