Add support for CHATHISTORY TARGETS
The main motivation is to avoid missing direct messages coming from other users. A nice side-effect is that we no longer need to issue CHATHISTORY queries for each channel we JOIN: instead, we can only fetch history for targets known to have new messages available (as indicated by CHATHISTORY TARGETS). We use read receipts instead of delivery receipts, so that reloading the webapp restores the exact same state (ie, unread messages are re-fetched). References: https://github.com/ircv3/ircv3-specifications/pull/450
This commit is contained in:
parent
74d9dea5bb
commit
91208a6d47
2 changed files with 56 additions and 11 deletions
|
@ -575,6 +575,24 @@ export default class Client extends EventTarget {
|
|||
});
|
||||
}
|
||||
|
||||
fetchHistoryTargets(t1, t2) {
|
||||
var msg = {
|
||||
command: "CHATHISTORY",
|
||||
params: ["TARGETS", "timestamp=" + t1, "timestamp=" + t2, 1000],
|
||||
};
|
||||
return this.fetchBatch(msg, "draft/chathistory-targets").then((batch) => {
|
||||
return batch.messages.map((msg) => {
|
||||
if (msg.command != "CHATHISTORY" || msg.params[0] != "TARGETS") {
|
||||
throw new Error("Cannot fetch chat history targets: unexpected message " + msg);
|
||||
}
|
||||
return {
|
||||
name: msg.params[1],
|
||||
latestMessage: msg.params[2],
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
listBouncerNetworks() {
|
||||
if (!this.enabledCaps["soju.im/bouncer-networks"]) {
|
||||
return Promise.reject(new Error("Server doesn't support the BOUNCER extension"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue