exports.runQuery = function (matrixClient, room) { setInterval(() => { axios({ method: 'GET', url: `${config.fediverse.domain}/api/v1/timelines/home`, headers: { Authorization: `Bearer ${fediverse_auth.access_token}` }, }).then((events) => { let lastEvent = JSON.parse(localStorage.getItem('timeline')); localStorage.setItem('timeline', JSON.stringify(events.data[0].created_at, null, 2)); if (lastEvent !== events.data[0].created_at) { if (events.data[0].reblog === null) { matrixClient.sendHtmlNotice(room.roomId, '', `${events.data[0].account.acct}
${events.data[0].content}
${events.data[0].media_attachments.map(media => ``+`${media.description}`+'' ).join('
')} (id: ${events.data[0].id}) ${registrar.media.visibilityEmoji(events.data[0].visibility)}
`); } else { matrixClient.sendHtmlNotice(room.roomId, '', ` ${events.data[0].account.acct} has repeated:
${events.data[0].reblog.account.acct}
${events.data[0].content}
${events.data[0].media_attachments.map(media => ``+`Proxied image, no description available.`+'' ).join('
')}
(id: ${events.data[0].id}) ${registrar.media.visibilityEmoji(events.data[0].visibility)}
`); } } }); }, 8000); };