stub handler for identity registration
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 37s Details

This commit is contained in:
Ladd Hoffman 2024-04-26 18:31:34 -05:00
parent 6a2b647b4b
commit fe5fe522ab
2 changed files with 33 additions and 8 deletions

View File

@ -67,7 +67,7 @@ const start = async () => {
// Leave targetRoomId uninitialized for now
}
async function handleCommand(roomId, event) {
const handleCommand = async (roomId, event) => {
// Don't handle unhelpful events (ones that aren't text messages, are redacted, or sent by us)
if (event.content?.msgtype !== 'm.text') return;
if (event.sender === await client.getUserId()) return;
@ -101,11 +101,29 @@ const start = async () => {
// Not found
}
}
}
};
const handleRegisterIdentity = async (roomId, event) => {
// const { message, signature } = event.content;
await client.replyNotice(roomId, event, 'Received request to register identity');
};
// Before we start the bot, register our command handler
client.on('room.message', handleCommand);
// Handler for custom events
client.on('room.event', (roomId, event) => {
// Note that state events can also be sent down this listener too
if (event.state_key !== undefined) return; // state event
switch (event.type) {
case 'io.dgov.identity.register':
handleRegisterIdentity(roomId, event);
break;
default:
}
});
client.start().then(() => {
console.log('Bot started!');
outboundQueue.resume();

View File

@ -368,13 +368,20 @@ function Widget() {
setShowViewPost(true);
}, [setViewPost, setShowViewPost]);
// TODO: Sign and send a message to the forum-api bot / to a room in matrix
const registerMatrixIdentity = async () => {
await widgetApi.current.sendRoomEvent('m.room.message', {
body: 'test message',
msgtype: 'm.text',
const registerMatrixIdentity = useCallback(async () => {
const message = new Date().toISOString();
const signature = await provider.request({
method: 'personal_sign',
params: [message, account],
});
};
// TODO: Sign and send a message
await widgetApi.current.sendRoomEvent('io.dgov.identity.register', {
message,
signature,
});
}, [provider, account]);
/* -------------------------------------------------------------------------------- */
/* --------------------------- END UI ACTIONS ------------------------------------- */