mirror of
https://github.com/plantroon/mx-puppet-xmpp.git
synced 2024-11-14 15:31:40 +00:00
room-namespace event ids
This commit is contained in:
parent
3f161b27cb
commit
179c6ca7dc
29
src/skype.ts
29
src/skype.ts
@ -105,10 +105,11 @@ export class Skype {
|
||||
if (!contact || !conversation) {
|
||||
return null;
|
||||
}
|
||||
const room = this.getRoomParams(puppetId, conversation);
|
||||
return {
|
||||
user: this.getUserParams(puppetId, contact),
|
||||
room: this.getRoomParams(puppetId, conversation),
|
||||
eventId: resource.id, // tslint:disable-line no-any
|
||||
room,
|
||||
eventId: `${resource.id};${room.roomId}`,
|
||||
};
|
||||
}
|
||||
|
||||
@ -378,7 +379,7 @@ export class Skype {
|
||||
const eventId = ret && ret.MessageId;
|
||||
this.messageDeduplicator.unlock(dedupeKey, p.client.username, eventId);
|
||||
if (eventId) {
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, eventId);
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, `${eventId};${room.roomId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,11 +402,11 @@ export class Skype {
|
||||
}
|
||||
const dedupeKey = `${room.puppetId};${room.roomId}`;
|
||||
this.messageDeduplicator.lock(dedupeKey, p.client.username, msg);
|
||||
await p.client.sendEdit(conversation.id, eventId, msg);
|
||||
await p.client.sendEdit(conversation.id, eventId.split(";")[0], msg);
|
||||
const newEventId = "";
|
||||
this.messageDeduplicator.unlock(dedupeKey, p.client.username, newEventId);
|
||||
if (newEventId) {
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, newEventId);
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, `${newEventId};${room.roomId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -431,7 +432,7 @@ export class Skype {
|
||||
const ownContact = await p.client.getContact(p.client.username);
|
||||
const authorname = escapeHtml(ownContact ? ownContact.displayName : p.client.username);
|
||||
const conversationId = escapeHtml(conversation.id);
|
||||
const timestamp = Math.round(Number(eventId) / 1000).toString();
|
||||
const timestamp = Math.round(Number(eventId.split(";")[0]) / 1000).toString();
|
||||
const origEventId = (await this.puppet.eventSync.getMatrix(room.puppetId, eventId))[0];
|
||||
let contents = "blah";
|
||||
if (origEventId) {
|
||||
@ -451,7 +452,7 @@ export class Skype {
|
||||
}
|
||||
}
|
||||
const quote = `<quote author="${author}" authorname="${authorname}" timestamp="${timestamp}" ` +
|
||||
`conversation="${conversationId}" messageid="${escapeHtml(eventId)}">` +
|
||||
`conversation="${conversationId}" messageid="${escapeHtml(eventId.split(";")[0])}">` +
|
||||
`<legacyquote>[${timestamp}] ${authorname}: </legacyquote>${contents}<legacyquote>
|
||||
|
||||
<<< </legacyquote></quote>`;
|
||||
@ -462,7 +463,7 @@ export class Skype {
|
||||
const newEventId = ret && ret.MessageId;
|
||||
this.messageDeduplicator.unlock(dedupeKey, p.client.username, newEventId);
|
||||
if (newEventId) {
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, newEventId);
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, `${newEventId};${room.roomId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,7 +479,7 @@ export class Skype {
|
||||
return;
|
||||
}
|
||||
p.deletedMessages.add(eventId);
|
||||
await p.client.sendDelete(conversation.id, eventId);
|
||||
await p.client.sendDelete(conversation.id, eventId.split(";")[0]);
|
||||
}
|
||||
|
||||
public async handleMatrixImage(room: IRemoteRoom, data: IFileEvent) {
|
||||
@ -522,7 +523,7 @@ export class Skype {
|
||||
const eventId = ret && ret.MessageId;
|
||||
this.messageDeduplicator.unlock(dedupeKey, p.client.username, eventId);
|
||||
if (eventId) {
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, eventId);
|
||||
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, `${eventId};${room.roomId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -578,7 +579,7 @@ export class Skype {
|
||||
const messageid = quote.attr("messageid");
|
||||
if (messageid) {
|
||||
const sendQuoteMsg = this.skypeMessageParser.parse(msg, { noQuotes: true });
|
||||
await this.puppet.sendReply(params, messageid, sendQuoteMsg);
|
||||
await this.puppet.sendReply(params, `${messageid};${params.room.roomId}`, sendQuoteMsg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -635,12 +636,12 @@ export class Skype {
|
||||
sendMsg.emote = true;
|
||||
}
|
||||
if (resource.content) {
|
||||
await this.puppet.sendEdit(params, resource.id, sendMsg);
|
||||
} else if (p.deletedMessages.has(resource.id)) {
|
||||
await this.puppet.sendEdit(params, `${resource.id};${params.room.roomId}`, sendMsg);
|
||||
} else if (p.deletedMessages.has(`${resource.id};${params.room.roomId}`)) {
|
||||
log.silly("normal message redact dedupe");
|
||||
return;
|
||||
} else {
|
||||
await this.puppet.sendRedact(params, resource.id);
|
||||
await this.puppet.sendRedact(params, `${resource.id};${params.room.roomId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user