exports.runQuery = function (matrixClient, room) { setInterval(() => { axios({ method: 'GET', url: `${config.fediverse.domain}/api/v1/notifications`, headers: { Authorization: `Bearer ${fediverse_auth.access_token}` }, }).then((events) => { let lastEvent = JSON.parse(localStorage.getItem('notifications')); localStorage.setItem('notifications', JSON.stringify(events.data[0].created_at, null, 2)); if (lastEvent !== events.data[0].created_at) { if (events.data[0].type === 'follow') { matrixClient.sendHtmlNotice(room.roomId, '', ` ${events.data[0].account.acct} has followed you.
${events.data[0].account.note}`); } else if (events.data[0].type === 'favourite') { matrixClient.sendHtmlNotice(room.roomId, '', ` ${events.data[0].account.acct} has favorited your post:
${events.data[0].status.content}
`); } else if (events.data[0].type === 'mention') { matrixClient.sendHtmlNotice(room.roomId, '', ` ${events.data[0].account.acct} has mentioned you:
${events.data[0].status.content}
(id: ${events.data[0].status.id}) ${registrar.media.visibilityEmoji(events.data[0].status.visibility)}
`); } else if (events.data[0].type === 'reblog') { matrixClient.sendHtmlNotice(room.roomId, '', ` ${events.data[0].account.acct} has repeated your post:
${events.data[0].status.content}
`); } } }); }, 8000); };