Command to restart a matrix pool
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 28s Details

This commit is contained in:
Ladd Hoffman 2024-05-04 20:05:39 -05:00
parent 4fe17240a6
commit efef9e8169
1 changed files with 14 additions and 1 deletions

View File

@ -1,13 +1,15 @@
const { registerMatrixMessageHandler } = require('../matrix-bot');
const { setTargetRoomId } = require('../matrix-bot/outbound-queue');
const {
appState,
proposalEventIds,
matrixPools,
} = require('../util/db');
const submitRollup = require('./rollup/submit-rollup');
const { resetBatchItems } = require('./rollup/batch-items');
const { initiateMatrixPools } = require('./rollup/matrix-pools/initiate-matrix-pools');
const initiateMatrixPool = require('./rollup/matrix-pools/initiate');
const read = require('../util/forum/read');
const {
BOT_INSTANCE_ID,
@ -25,6 +27,7 @@ const handleCommand = async (client, roomId, event) => {
const proposalRegex = /\bprop(|osal) ([0-9]+)\b/i;
const submitRollupRegex = /^!submitBatch\b/i;
const resetBatchRegex = /^!resetBatch (.*)\b/i;
const restartMatrixPoolRegex = /^!restartMatrixPool (.*)\b/i;
const { body } = event.content;
@ -75,6 +78,16 @@ const handleCommand = async (client, roomId, event) => {
await initiateMatrixPools();
await client.replyText(roomId, event, `Reset batch, now contains ${batchItems.length} items`);
}
} else if (restartMatrixPoolRegex.test(body)) {
const [, postId] = restartMatrixPoolRegex.exec(body);
console.log(`!restartMatrixPool roomId ${roomId} postId ${postId}`);
try {
const { sender, fee } = await matrixPools.get(postId);
const post = await read(postId);
await initiateMatrixPool(postId, post, sender, fee);
} catch (e) {
// Can't restart if it was never started
}
}
};