feat(matrix/fediverse): allow users to directly reply on Fediverse posts from Matrix, using <mx-reply> on our new meta field.
feat(matrix/fediverse): allow users to favorite, reblog, and redact Fediverse posts from Matrix, using m.reaction on our new meta field. feat(fediverse): add suggestions for follow/unfollow commands. refactor(matrix/fediverse): add meta field for commands by reaction, and commands by reply. refactor(fediverse): relax polling on timeline/notifs thru new handling.
This commit is contained in:
parent
430fb350c1
commit
42563ebc35
26 changed files with 619 additions and 375 deletions
|
@ -1,39 +1,26 @@
|
|||
exports.runQuery = function (matrixClient, room) {
|
||||
exports.runQuery = function (roomId) {
|
||||
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,
|
||||
'',
|
||||
`<b><a href="${config.fediverse.domain}/notice/${events.data[0].id}">${events.data[0].account.acct}</a>
|
||||
<blockquote><i>${events.data[0].content}</i><br>
|
||||
${events.data[0].media_attachments.map(media =>
|
||||
`<a href="${media.remote_url}">`+`${media.description}`+'</a>'
|
||||
).join('<br>')}
|
||||
(id: ${events.data[0].id}) ${registrar.media.visibilityEmoji(events.data[0].visibility)}
|
||||
</blockquote>`);
|
||||
} else {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b><a href="${config.fediverse.domain}/${events.data[0].account.id}">
|
||||
${events.data[0].account.acct}</a>
|
||||
<font color="#7886D7">has <a href="${config.fediverse.domain}/notice/${events.data[0].id}">repeated</a>:
|
||||
<blockquote><a href="${events.data[0].reblog.account.url}">${events.data[0].reblog.account.acct}</a></blockquote>
|
||||
<blockquote>${events.data[0].content}<br>
|
||||
${events.data[0].media_attachments.map(media =>
|
||||
`<a href="${media.remote_url}">`+`Proxied image, no description available.`+'</a>'
|
||||
).join('<br>')}
|
||||
<br>(id: ${events.data[0].id}) ${registrar.media.visibilityEmoji(events.data[0].visibility)}
|
||||
</blockquote>`);
|
||||
headers: { Authorization: `Bearer ${fediverse.auth.access_token}` },
|
||||
})
|
||||
.then((res) => {
|
||||
let past = JSON.parse(localStorage.getItem('timeline'));
|
||||
if (past.length === 0) past = res.data;
|
||||
const events = res.data;
|
||||
const len = events.length;
|
||||
for (let i = len - 1; i >= 0; i--) {
|
||||
if (past.findIndex((x) => x.created_at === events[i].created_at) === -1) {
|
||||
if (events[i].created_at < past.slice(18, 19)[0].created_at) return;
|
||||
events[i].label = 'status';
|
||||
fediverse.utils.formatter(events[i], roomId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 8000);
|
||||
localStorage.setItem('timeline', JSON.stringify(events, null, 2));
|
||||
})
|
||||
.catch((e) => {
|
||||
matrix.utils.sendError(null, roomId, e);
|
||||
});
|
||||
}, 30000);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue