mirror of
https://github.com/plantroon/mx-puppet-xmpp.git
synced 2024-12-28 17:41:41 +00:00
send read reciepts
This commit is contained in:
parent
79dc0295cf
commit
5bc2c64859
@ -77,7 +77,9 @@ export class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "ThreadActivity":
|
case "ThreadActivity":
|
||||||
// log.silly(resource);
|
if (subtype === "MemberConsumptionHorizonUpdate") {
|
||||||
|
this.emit("presence", resource);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
53
src/skype.ts
53
src/skype.ts
@ -106,6 +106,7 @@ export class Skype {
|
|||||||
if (!p) {
|
if (!p) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
p.client = new Client(p.data.username, p.data.password);
|
||||||
const client = p.client;
|
const client = p.client;
|
||||||
client.on("text", async (resource: skypeHttp.resources.TextResource) => {
|
client.on("text", async (resource: skypeHttp.resources.TextResource) => {
|
||||||
try {
|
try {
|
||||||
@ -137,11 +138,18 @@ export class Skype {
|
|||||||
});
|
});
|
||||||
client.on("typing", async (resource: skypeHttp.resources.Resource, typing: boolean) => {
|
client.on("typing", async (resource: skypeHttp.resources.Resource, typing: boolean) => {
|
||||||
try {
|
try {
|
||||||
|
await this.handleSkypeTyping(puppetId, resource, typing);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.error("Error while handling typing event", err);
|
log.error("Error while handling typing event", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
client.on("presence", async (resource: skypeHttp.resources.Resource) => {
|
||||||
|
try {
|
||||||
|
await this.handleSkypePresence(puppetId, resource);
|
||||||
|
} catch (err) {
|
||||||
|
log.error("Error while handling presence event", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
await client.connect();
|
await client.connect();
|
||||||
await this.puppet.setUserId(puppetId, client.username);
|
await this.puppet.setUserId(puppetId, client.username);
|
||||||
}
|
}
|
||||||
@ -412,4 +420,47 @@ export class Skype {
|
|||||||
const buffer = await p.client.downloadFile(resource.uri);
|
const buffer = await p.client.downloadFile(resource.uri);
|
||||||
await this.puppet.sendFileDetect(params, buffer, filename);
|
await this.puppet.sendFileDetect(params, buffer, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async handleSkypeTyping(puppetId: number, resource: skypeHttp.resources.Resource, typing: boolean) {
|
||||||
|
const p = this.puppets[puppetId];
|
||||||
|
if (!p) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("Got new skype typing event");
|
||||||
|
log.silly(resource);
|
||||||
|
const params = await this.getSendParams(puppetId, resource);
|
||||||
|
if (!params) {
|
||||||
|
log.warn("Couldn't generate params");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await this.puppet.setUserTyping(params, typing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async handleSkypePresence(puppetId: number, resource: skypeHttp.resources.Resource) {
|
||||||
|
const p = this.puppets[puppetId];
|
||||||
|
if (!p || !resource.native) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("Got new skype presence event");
|
||||||
|
log.silly(resource);
|
||||||
|
const content = JSON.parse(resource.native.content);
|
||||||
|
const contact = await p.client.getContact(content.user);
|
||||||
|
const conversation = await p.client.getConversation({
|
||||||
|
puppetId,
|
||||||
|
roomId: resource.conversation,
|
||||||
|
});
|
||||||
|
if (!contact || !conversation) {
|
||||||
|
log.warn("Couldn't generate params");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const params: IReceiveParams = {
|
||||||
|
user: this.getUserParams(puppetId, contact),
|
||||||
|
room: this.getRoomParams(puppetId, conversation),
|
||||||
|
};
|
||||||
|
const [id, _, clientId] = content.consumptionhorizon.split(";");
|
||||||
|
params.eventId = id;
|
||||||
|
await this.puppet.sendReadReceipt(params);
|
||||||
|
params.eventId = clientId;
|
||||||
|
await this.puppet.sendReadReceipt(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user