Add remote/local event id sync
This commit is contained in:
parent
48549da20d
commit
d8412e921e
|
@ -36,7 +36,8 @@ export class VkPuppet {
|
||||||
private puppet: PuppetBridge,
|
private puppet: PuppetBridge,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
public async getSendParams(puppetId: number, peerId: number, senderId: number): Promise<IReceiveParams> {
|
public async getSendParams(puppetId: number, peerId: number, senderId: number, eventId?: string | undefined):
|
||||||
|
Promise<IReceiveParams> {
|
||||||
// we will use this function internally to create the send parameters
|
// we will use this function internally to create the send parameters
|
||||||
// needed to send a message, a file, reactions, ... to matrix
|
// needed to send a message, a file, reactions, ... to matrix
|
||||||
log.info(`Creating send params for ${peerId}...`);
|
log.info(`Creating send params for ${peerId}...`);
|
||||||
|
@ -44,6 +45,7 @@ export class VkPuppet {
|
||||||
return {
|
return {
|
||||||
room: await this.getRemoteRoom(puppetId, peerId),
|
room: await this.getRemoteRoom(puppetId, peerId),
|
||||||
user: await this.getRemoteUser(puppetId, senderId),
|
user: await this.getRemoteUser(puppetId, senderId),
|
||||||
|
eventId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +176,7 @@ export class VkPuppet {
|
||||||
message: data.body,
|
message: data.body,
|
||||||
random_id: new Date().getTime(),
|
random_id: new Date().getTime(),
|
||||||
});
|
});
|
||||||
|
await this.puppet.eventSync.insert(room, data.eventId!, response.toString());
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.error("Error sending to vk", err.error || err.body || err);
|
log.error("Error sending to vk", err.error || err.body || err);
|
||||||
}
|
}
|
||||||
|
@ -211,7 +214,7 @@ export class VkPuppet {
|
||||||
}
|
}
|
||||||
log.info("Received new message!", context);
|
log.info("Received new message!", context);
|
||||||
|
|
||||||
const params = await this.getSendParams(puppetId, context.peerId, context.senderId);
|
const params = await this.getSendParams(puppetId, context.peerId, context.senderId, context.id.toString());
|
||||||
|
|
||||||
if (context.hasText && !context.isOutbox) {
|
if (context.hasText && !context.isOutbox) {
|
||||||
const opts = {
|
const opts = {
|
||||||
|
|
Loading…
Reference in a new issue