update eventSync

This commit is contained in:
Sorunome 2020-04-25 17:29:38 +02:00
parent a9362adb24
commit 34f46e8c51
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
3 changed files with 67 additions and 72 deletions

103
package-lock.json generated
View File

@ -33,9 +33,9 @@
"integrity": "sha512-lXKXfypKo644k4Da4yXkPCrwcvn6SlUW2X2zFbuflKHNjf0w9htru01bo26uMhleMXsDmnZ12eJLdrAZa9MANg==" "integrity": "sha512-lXKXfypKo644k4Da4yXkPCrwcvn6SlUW2X2zFbuflKHNjf0w9htru01bo26uMhleMXsDmnZ12eJLdrAZa9MANg=="
}, },
"@sorunome/matrix-bot-sdk": { "@sorunome/matrix-bot-sdk": {
"version": "0.5.3-1", "version": "0.5.3-2",
"resolved": "https://registry.npmjs.org/@sorunome/matrix-bot-sdk/-/matrix-bot-sdk-0.5.3-1.tgz", "resolved": "https://registry.npmjs.org/@sorunome/matrix-bot-sdk/-/matrix-bot-sdk-0.5.3-2.tgz",
"integrity": "sha512-WzYyN6jAtGGsDdYOVXqK0BZxPxw9aI1bNXOT7YViw76QWVmn9RnJjhzJqX5GcOsYunecltWEyrLiK/WN0PM+hA==", "integrity": "sha512-kGbz+EudtS8iISEyfNnJEa29lA3tqzE7jUwaXUdkYqo2QuiNS0xnXi5zJDJoCycQEf5v0bWbVdtM+dEIilpTew==",
"requires": { "requires": {
"@types/express": "^4.17.2", "@types/express": "^4.17.2",
"chalk": "^3.0.0", "chalk": "^3.0.0",
@ -177,9 +177,9 @@
} }
}, },
"@types/express-serve-static-core": { "@types/express-serve-static-core": {
"version": "4.17.4", "version": "4.17.5",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.4.tgz", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.5.tgz",
"integrity": "sha512-dPs6CaRWxsfHbYDVU51VjEJaUJEcli4UI0fFMT4oWmgCvHj+j7oIxz5MLHVL0Rv++N004c21ylJNdWQvPkkb5w==", "integrity": "sha512-578YH5Lt88AKoADy0b2jQGwJtrBxezXtVe/MBqWXKZpqx91SnC0pVkVCcxcytz3lWW+cHBYDi3Ysh0WXc+rAYw==",
"requires": { "requires": {
"@types/node": "*", "@types/node": "*",
"@types/range-parser": "*" "@types/range-parser": "*"
@ -429,13 +429,6 @@
"qs": "6.7.0", "qs": "6.7.0",
"raw-body": "2.4.0", "raw-body": "2.4.0",
"type-is": "~1.6.17" "type-is": "~1.6.17"
},
"dependencies": {
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
}
} }
}, },
"boolbase": { "boolbase": {
@ -459,9 +452,9 @@
"optional": true "optional": true
}, },
"buffer": { "buffer": {
"version": "5.5.0", "version": "5.6.0",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.5.0.tgz", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
"integrity": "sha512-9FTEDjLjwoAkEwyMGDjYJQN2gfRgOKBKRfiglhvibGbpeeU/pQn1bJxQqm32OD/AIeEuHxU9roxXxg34Byp/Ww==", "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
"requires": { "requires": {
"base64-js": "^1.0.2", "base64-js": "^1.0.2",
"ieee754": "^1.1.4" "ieee754": "^1.1.4"
@ -921,11 +914,6 @@
"vary": "~1.1.2" "vary": "~1.1.2"
}, },
"dependencies": { "dependencies": {
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
},
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
@ -1436,16 +1424,16 @@
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
}, },
"mime-db": { "mime-db": {
"version": "1.43.0", "version": "1.44.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
"integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
}, },
"mime-types": { "mime-types": {
"version": "2.1.26", "version": "2.1.27",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
"integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
"requires": { "requires": {
"mime-db": "1.43.0" "mime-db": "1.44.0"
} }
}, },
"mimic-response": { "mimic-response": {
@ -1531,11 +1519,11 @@
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}, },
"mx-puppet-bridge": { "mx-puppet-bridge": {
"version": "0.0.38-1", "version": "0.0.39",
"resolved": "https://registry.npmjs.org/mx-puppet-bridge/-/mx-puppet-bridge-0.0.38-1.tgz", "resolved": "https://registry.npmjs.org/mx-puppet-bridge/-/mx-puppet-bridge-0.0.39.tgz",
"integrity": "sha512-69kQ2ntuzcmA8cn8S5dIxSUcuy31wDjpSeWSIjF+9osdALS/XTwh7/OVlTkUk4Wjh5WAeXba4na36BF80MTMYw==", "integrity": "sha512-0Lw7E06tbxci1V4Gkiijd8kdCU3o0PrTjxOBuoGI3zieOu7osAZ1TMzQ3rZKZddtboN8oy9h4/GkTqsIf9T67Q==",
"requires": { "requires": {
"@sorunome/matrix-bot-sdk": "^0.5.3-1", "@sorunome/matrix-bot-sdk": "^0.5.3-2",
"better-sqlite3": "^6.0.1", "better-sqlite3": "^6.0.1",
"events": "^3.1.0", "events": "^3.1.0",
"expire-set": "^1.0.0", "expire-set": "^1.0.0",
@ -1561,9 +1549,9 @@
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
}, },
"node-abi": { "node-abi": {
"version": "2.15.0", "version": "2.16.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.15.0.tgz", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.16.0.tgz",
"integrity": "sha512-FeLpTS0F39U7hHZU1srAK4Vx+5AHNVOTP+hxBNQknR/54laTHSFIJkDWDqiquY1LeLUgTfPN7sLPhMubx0PLAg==", "integrity": "sha512-+sa0XNlWDA6T+bDLmkCUYn6W5k5W6BPRL6mqzSCs6H/xUgtl4D5x2fORKDzopKiU6wsyn/+wXlRXwXeSp+mtoA==",
"requires": { "requires": {
"semver": "^5.4.1" "semver": "^5.4.1"
} }
@ -1719,15 +1707,15 @@
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
}, },
"pg": { "pg": {
"version": "8.0.0", "version": "8.0.3",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.0.0.tgz", "resolved": "https://registry.npmjs.org/pg/-/pg-8.0.3.tgz",
"integrity": "sha512-jinx9Xcmkeh7Y7gatu2EJiXr37mcDeF0G5X14MjqPMwYjoZMk7PMMSTTXQQl03GRp2IICxo/zyybqfv2RNgXsg==", "integrity": "sha512-fvcNXn4o/iq4jKq15Ix/e58q3jPSmzOp6/8C3CaHoSR/bsxdg+1FXfDRePdtE/zBb3++TytvOrS1hNef3WC/Kg==",
"requires": { "requires": {
"buffer-writer": "2.0.0", "buffer-writer": "2.0.0",
"packet-reader": "1.0.0", "packet-reader": "1.0.0",
"pg-connection-string": "0.1.3", "pg-connection-string": "0.1.3",
"pg-packet-stream": "^1.1.0", "pg-pool": "^3.1.1",
"pg-pool": "^3.0.0", "pg-protocol": "^1.2.2",
"pg-types": "^2.1.0", "pg-types": "^2.1.0",
"pgpass": "1.x", "pgpass": "1.x",
"semver": "4.3.2" "semver": "4.3.2"
@ -1755,27 +1743,27 @@
"resolved": "https://registry.npmjs.org/pg-minify/-/pg-minify-1.5.2.tgz", "resolved": "https://registry.npmjs.org/pg-minify/-/pg-minify-1.5.2.tgz",
"integrity": "sha512-uZn/gXkGmO5JBdopxNLSpFMS1lXr+KJqynI8Di1Qyr8ZVXt67ruh+XNfzLMVdLzYv+MQRdNYQdVwWPSs0qM7xQ==" "integrity": "sha512-uZn/gXkGmO5JBdopxNLSpFMS1lXr+KJqynI8Di1Qyr8ZVXt67ruh+XNfzLMVdLzYv+MQRdNYQdVwWPSs0qM7xQ=="
}, },
"pg-packet-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/pg-packet-stream/-/pg-packet-stream-1.1.0.tgz",
"integrity": "sha512-kRBH0tDIW/8lfnnOyTwKD23ygJ/kexQVXZs7gEyBljw4FYqimZFxnMMx50ndZ8In77QgfGuItS5LLclC2TtjYg=="
},
"pg-pool": { "pg-pool": {
"version": "3.1.0", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.1.0.tgz", "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.1.1.tgz",
"integrity": "sha512-CvxGctDwjZZad6Q7vvhFA4BsYdk26UFIZaFH0XXqHId5uBOc26vco/GFh/laUVIQUpD9IKe/f9/mr/OQHyQ2ZA==" "integrity": "sha512-kYH6S0mcZF1TPg1F9boFee2JlCSm2oqnlR2Mz2Wgn1psQbEBNVeNTJCw2wCK48QsctwvGUzbxLMg/lYV6hL/3A=="
}, },
"pg-promise": { "pg-promise": {
"version": "10.5.0", "version": "10.5.2",
"resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-10.5.0.tgz", "resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-10.5.2.tgz",
"integrity": "sha512-4eM/wnmymZA/NYqYojtK5OtZJNqdWKkHwYjT6zWIFnAWQyUnEsM8QWIgSAubGrzdf5rpsGnco8OjCoZxu3HCuw==", "integrity": "sha512-PsLE6SaPHoe7b5QJhoYeKeNcyTM4YYczTR0YwOKFtCVuLGejfA8nUHlaJEM7NUcORfidVxW7RPaXmY/aCf3Nqw==",
"requires": { "requires": {
"assert-options": "0.6.1", "assert-options": "0.6.1",
"pg": "8.0.0", "pg": "8.0.3",
"pg-minify": "1.5.2", "pg-minify": "1.5.2",
"spex": "3.0.1" "spex": "3.0.1"
} }
}, },
"pg-protocol": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.2.2.tgz",
"integrity": "sha512-r8hGxHOk3ccMjjmhFJ/QOSVW5A+PP84TeRlEwB/cQ9Zu+bvtZg8Z59Cx3AMfVQc9S0Z+EG+HKhicF1W1GN5Eqg=="
},
"pg-types": { "pg-types": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
@ -1832,9 +1820,9 @@
"integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU="
}, },
"postgres-date": { "postgres-date": {
"version": "1.0.4", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.4.tgz", "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.5.tgz",
"integrity": "sha512-bESRvKVuTrjoBluEcpv2346+6kgB7UlnqWZsnbnCccTNq/pqfj1j6oBaN5+b/NrDXepYUT/HKadqv3iS9lJuVA==" "integrity": "sha512-pdau6GRPERdAYUQwkBnGKxEfPyhVZXG/JiS44iZWiNdSOWE09N2lUgN6yshuq6fVSon4Pm0VMXd1srUUkLe9iA=="
}, },
"postgres-interval": { "postgres-interval": {
"version": "1.2.0", "version": "1.2.0",
@ -1899,6 +1887,11 @@
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
}, },
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
},
"range-parser": { "range-parser": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",

View File

@ -20,7 +20,7 @@
"events": "^3.0.0", "events": "^3.0.0",
"expire-set": "^1.0.0", "expire-set": "^1.0.0",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"mx-puppet-bridge": "0.0.38-1", "mx-puppet-bridge": "0.0.39",
"node-emoji": "^1.10.0", "node-emoji": "^1.10.0",
"node-html-parser": "^1.2.13", "node-html-parser": "^1.2.13",
"tslint": "^5.17.0", "tslint": "^5.17.0",

View File

@ -378,7 +378,7 @@ export class Skype {
const eventId = ret && ret.MessageId; const eventId = ret && ret.MessageId;
this.messageDeduplicator.unlock(dedupeKey, p.client.username, eventId); this.messageDeduplicator.unlock(dedupeKey, p.client.username, eventId);
if (eventId) { if (eventId) {
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, eventId); await this.puppet.eventSync.insert(room, data.eventId!, eventId);
} }
} }
@ -405,7 +405,7 @@ export class Skype {
const newEventId = ""; const newEventId = "";
this.messageDeduplicator.unlock(dedupeKey, p.client.username, newEventId); this.messageDeduplicator.unlock(dedupeKey, p.client.username, newEventId);
if (newEventId) { if (newEventId) {
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, newEventId); await this.puppet.eventSync.insert(room, data.eventId!, newEventId);
} }
} }
@ -432,13 +432,14 @@ export class Skype {
const authorname = escapeHtml(ownContact ? ownContact.displayName : p.client.username); const authorname = escapeHtml(ownContact ? ownContact.displayName : p.client.username);
const conversationId = escapeHtml(conversation.id); const conversationId = escapeHtml(conversation.id);
const timestamp = Math.round(Number(eventId) / 1000).toString(); const timestamp = Math.round(Number(eventId) / 1000).toString();
const origEventId = (await this.puppet.eventSync.getMatrix(room.puppetId, eventId))[0]; const origEventId = (await this.puppet.eventSync.getMatrix(room, eventId))[0];
let contents = "blah"; let contents = "blah";
if (origEventId) { if (origEventId) {
const [realOrigEventId, roomId] = origEventId.split(";"); const roomId = await this.puppet.roomSync.maybeGetMxid(room);
if (roomId) {
try { try {
const client = (await this.puppet.roomSync.getRoomOp(roomId)) || this.puppet.botIntent.underlyingClient; const client = (await this.puppet.roomSync.getRoomOp(roomId)) || this.puppet.botIntent.underlyingClient;
const evt = await client.getEvent(roomId, realOrigEventId); const evt = await client.getEvent(roomId, origEventId);
if (evt && evt.content && typeof evt.content.body === "string") { if (evt && evt.content && typeof evt.content.body === "string") {
if (evt.content.formatted_body) { if (evt.content.formatted_body) {
contents = this.matrixMessageParser.parse(evt.content.formatted_body); contents = this.matrixMessageParser.parse(evt.content.formatted_body);
@ -450,6 +451,7 @@ export class Skype {
log.verbose("Event not found", err.body || err); log.verbose("Event not found", err.body || err);
} }
} }
}
const quote = `<quote author="${author}" authorname="${authorname}" timestamp="${timestamp}" ` + const quote = `<quote author="${author}" authorname="${authorname}" timestamp="${timestamp}" ` +
`conversation="${conversationId}" messageid="${escapeHtml(eventId)}">` + `conversation="${conversationId}" messageid="${escapeHtml(eventId)}">` +
`<legacyquote>[${timestamp}] ${authorname}: </legacyquote>${contents}<legacyquote> `<legacyquote>[${timestamp}] ${authorname}: </legacyquote>${contents}<legacyquote>
@ -462,7 +464,7 @@ export class Skype {
const newEventId = ret && ret.MessageId; const newEventId = ret && ret.MessageId;
this.messageDeduplicator.unlock(dedupeKey, p.client.username, newEventId); this.messageDeduplicator.unlock(dedupeKey, p.client.username, newEventId);
if (newEventId) { if (newEventId) {
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, newEventId); await this.puppet.eventSync.insert(room, data.eventId!, newEventId);
} }
} }
@ -522,7 +524,7 @@ export class Skype {
const eventId = ret && ret.MessageId; const eventId = ret && ret.MessageId;
this.messageDeduplicator.unlock(dedupeKey, p.client.username, eventId); this.messageDeduplicator.unlock(dedupeKey, p.client.username, eventId);
if (eventId) { if (eventId) {
await this.puppet.eventSync.insert(room.puppetId, data.eventId!, eventId); await this.puppet.eventSync.insert(room, data.eventId!, eventId);
} }
} }