Support persistent Matrix sims for webhooks

This commit is contained in:
Cadence Ember
2025-11-19 16:37:39 +13:00
parent ce30272389
commit edd4f988ec
9 changed files with 234 additions and 17 deletions
+2 -9
View File
@@ -13,13 +13,6 @@ const file = sync.require("../../matrix/file")
/** @type {import("./register-user")} */
const registerUser = sync.require("./register-user")
/**
* @typedef WebhookAuthor Discord API message->author. A webhook as an author.
* @prop {string} username
* @prop {string?} avatar
* @prop {string} id
*/
/** @returns {Promise<Ty.PkMessage>} */
async function fetchMessage(messageID) {
try {
@@ -111,7 +104,7 @@ async function ensureSimJoined(pkMessage, roomID) {
/**
* Generate profile data based on webhook displayname and configured avatar.
* @param {Ty.PkMessage} pkMessage
* @param {WebhookAuthor} author
* @param {Ty.WebhookAuthor} author
*/
async function memberToStateContent(pkMessage, author) {
// We prefer to use the member's avatar URL data since the image upload can be cached across channels,
@@ -137,7 +130,7 @@ async function memberToStateContent(pkMessage, author) {
* 5. Compare against the previously known state content, which is helpfully stored in the database
* 6. If the state content has changed, send it to Matrix and update it in the database for next time
* @param {string} messageID to call API with
* @param {WebhookAuthor} author for profile data
* @param {Ty.WebhookAuthor} author for profile data
* @param {string} roomID room to join member to
* @param {boolean} shouldActuallySync whether to actually sync updated user data or just ensure it's joined
* @returns {Promise<string>} mxid of the updated sim