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,18 +1,19 @@
|
|||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios.get(`${config.fediverse.domain}/api/v1/accounts/${userInput}`).then((findUID) => {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${config.fediverse.domain}/api/v1/accounts/${findUID.data.id}/unfollow`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
})
|
||||
.then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`Unsubscribed:
|
||||
<blockquote>${config.fediverse.domain}/${response.data.id}`);
|
||||
});
|
||||
}).catch((e) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'', `${e}`);
|
||||
exports.runQuery = async function (roomId, event, userInput) {
|
||||
const loadingString = `Searching for ${userInput}...`;
|
||||
const original = await matrixClient.sendHtmlNotice(roomId, `${loadingString}`, `<code>${loadingString}</code>`);
|
||||
const found = [];
|
||||
const suggest = [];
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: `${config.fediverse.domain}/api/v2/search?q=${userInput}&type=accounts`,
|
||||
headers: { Authorization: `Bearer ${fediverse.auth.access_token}` },
|
||||
}).then((findUserId) => {
|
||||
const results = findUserId.data.accounts;
|
||||
const len = results.length;
|
||||
for (let i = 0; i < len; i++) results[i].acct !== userInput ? suggest.push(results[i].acct) : found.push(results[i]);
|
||||
if (found.length > 0) return fediverse.utils.unfollow(roomId, found, event, original);
|
||||
if (suggest.length > 0) msg = `<code>${userInput} was not found, suggesting:</code><blockquote>${suggest.join('<br>')}</blockquote>`;
|
||||
if (suggest.length === 0) msg = `<code>No results found for: ${userInput}.</code>`;
|
||||
return matrix.utils.editNoticeHTML(roomId, original, msg);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue