feat(e2ee): introduce OLM encryption. refactor(storage): moved from fs to localstorage. refactor(config): added as global to registrar. chore(npm): upgraded matrix-js-sdk from 2.4.6 release to 9.5.1 release.
This commit is contained in:
parent
0cd373fb8a
commit
67b88f9c96
28 changed files with 264 additions and 1413 deletions
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, registrar) {
|
||||
exports.runQuery = function (matrixClient, room) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
data: { status: `@10grans@fedi.cc beg` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}/unfavourite`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses/${userInput}/unfavourite`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}/favourite`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses/${userInput}/favourite`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}/reblog`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses/${userInput}/reblog`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, registrar) {
|
||||
exports.runQuery = function (matrixClient, room) {
|
||||
setInterval(() => {
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/timelines/home`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/timelines/home`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((events) => {
|
||||
const event = fs.readFileSync('timeline.json', 'utf8');
|
||||
fs.writeFileSync('timeline.json', events.data[0].created_at, 'utf8');
|
||||
if (event !== events.data[0].created_at) {
|
||||
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="${registrar.config.fediverse.domain}/notice/${events.data[0].id}">${events.data[0].account.acct}</a>
|
||||
`<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>'
|
||||
|
@ -24,9 +22,9 @@ exports.runQuery = function (matrixClient, room, registrar) {
|
|||
} else {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b><a href="${registrar.config.fediverse.domain}/${events.data[0].account.id}">
|
||||
`<b><a href="${config.fediverse.domain}/${events.data[0].account.id}">
|
||||
${events.data[0].account.acct}</a>
|
||||
<font color="#7886D7">has <a href="${registrar.config.fediverse.domain}/notice/${events.data[0].id}">repeated</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 =>
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
const axios = require('axios');
|
||||
const fediverse_auth = JSON.parse(localStorage.getItem('fediverse_auth'));
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
axios.get(`${registrar.config.fediverse.domain}/api/v1/accounts/${userInput}`).then((findUID) => {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios.get(`${config.fediverse.domain}/api/v1/accounts/${userInput}`).then((findUID) => {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/accounts/${findUID.data.id}/follow`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/accounts/${findUID.data.id}/follow`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
})
|
||||
.then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`Subscribed:
|
||||
<blockquote>${registrar.config.fediverse.domain}/${response.data.id}`);
|
||||
<blockquote>${config.fediverse.domain}/${response.data.id}`);
|
||||
});
|
||||
}).catch((e) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const qs = require('qs');
|
||||
const axios = require('axios');
|
||||
const FormData = require('form-data');
|
||||
|
||||
const emojis = { public: '🌐', unlisted: '📝', private: '🔒️', direct: '✉️' };
|
||||
|
@ -26,7 +25,7 @@ const mediaDownload = async (url, { whitelist, blacklist }) => {
|
|||
};
|
||||
};
|
||||
|
||||
const mediaUpload = async ({ domain }, { data, filename, mimetype }, registrar) => {
|
||||
const mediaUpload = async ({ domain }, { data, filename, mimetype }) => {
|
||||
const form = new FormData();
|
||||
form.append('file', data, {
|
||||
filename: filename || 'upload',
|
||||
|
@ -35,24 +34,24 @@ const mediaUpload = async ({ domain }, { data, filename, mimetype }, registrar)
|
|||
const upload = await axios({
|
||||
method: 'POST',
|
||||
url: `${domain}/api/v1/media`,
|
||||
headers: form.getHeaders({ Authorization: `Bearer ${registrar.fediverse_auth.access_token}` }),
|
||||
headers: form.getHeaders({ Authorization: `Bearer ${fediverse_auth.access_token}` }),
|
||||
data: form,
|
||||
});
|
||||
if(upload.statusText !== 'OK') throw upload;
|
||||
return upload.data.id;
|
||||
};
|
||||
|
||||
const run = async (matrixClient, { roomId }, content, replyId, mediaURL, subject, registrar) => {
|
||||
const run = async (matrixClient, { roomId }, content, replyId, mediaURL, subject) => {
|
||||
let mediaId = null;
|
||||
const fediverse = registrar.config.fediverse;
|
||||
const fediverse = config.fediverse;
|
||||
if(mediaURL) {
|
||||
const media = await mediaDownload(mediaURL, registrar.config.fediverse.mimetypes);
|
||||
mediaId = await mediaUpload(fediverse, media, registrar);
|
||||
const media = await mediaDownload(mediaURL, fediverse.mimetypes);
|
||||
mediaId = await mediaUpload(fediverse, media);
|
||||
}
|
||||
const response = await axios({
|
||||
method: 'POST',
|
||||
url: `${fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}`, 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}`, 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
data : qs.stringify({
|
||||
status: content,
|
||||
content_type: `text/markdown`,
|
||||
|
@ -64,13 +63,13 @@ const run = async (matrixClient, { roomId }, content, replyId, mediaURL, subject
|
|||
return matrixClient.sendHtmlNotice(roomId, '', `<a href="${response.data.url}">${response.data.id}</a>`);
|
||||
}
|
||||
|
||||
exports.runQuery = async (client, room, userInput, registrar, { isReply, hasMedia, hasSubject }) => {
|
||||
exports.runQuery = async (client, room, userInput, { isReply, hasMedia, hasSubject }) => {
|
||||
try {
|
||||
const chunks = userInput.trim().split(' ');
|
||||
if(!chunks.length || chunks.length < !!isReply + !!hasMedia) throw '';
|
||||
let replyId = null;
|
||||
let mediaURL = null;
|
||||
const subject = hasSubject ? registrar.config.fediverse.subject : null;
|
||||
const subject = hasSubject ? fediverse.subject : null;
|
||||
if(isReply) {
|
||||
replyId = chunks[0];
|
||||
chunks.shift();
|
||||
|
@ -79,13 +78,13 @@ exports.runQuery = async (client, room, userInput, registrar, { isReply, hasMedi
|
|||
let url = new URL(chunks[0]);
|
||||
chunks.shift();
|
||||
if(url.protocol === 'mxc:' && url.hostname && url.pathname)
|
||||
url = new URL(`${registrar.config.matrix.domain}/_matrix/media/r0/download/${url.hostname}${url.pathname}`);
|
||||
url = new URL(`${config.matrix.domain}/_matrix/media/r0/download/${url.hostname}${url.pathname}`);
|
||||
if(url.protocol !== 'https:') throw '';
|
||||
if(!registrar.config.matrix.domains.includes(url.hostname)) throw '';
|
||||
if(!config.matrix.domains.includes(url.hostname)) throw '';
|
||||
if(!/^\/_matrix\/media\/r0\/download\/[^/]+\/[^/]+\/?$/.test(url.pathname)) throw '';
|
||||
mediaURL = url.toString();
|
||||
}
|
||||
return await run(client, room, chunks.join(' '), replyId, mediaURL, subject, registrar);
|
||||
return await run(client, room, chunks.join(' '), replyId, mediaURL, subject);
|
||||
} catch(e) {
|
||||
return client.sendHtmlNotice(room.roomId, 'Sad!', `<strong>Sad!</strong>`).catch(()=>{});
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
data: {
|
||||
status: `@mordekai ${userInput}`,
|
||||
content_type: `text/markdown`,
|
||||
|
|
|
@ -1,49 +1,45 @@
|
|||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, registrar) {
|
||||
exports.runQuery = function (matrixClient, room) {
|
||||
setInterval(() => {
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/notifications`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
}).then((notifications) => {
|
||||
const event = fs.readFileSync('notification.json', 'utf8');
|
||||
fs.writeFileSync('notification.json', notifications.data[0].created_at, 'utf8');
|
||||
|
||||
if (event !== notifications.data[0].created_at) {
|
||||
if (notifications.data[0].type === 'follow') {
|
||||
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,
|
||||
'',
|
||||
`<b><a href="${registrar.config.fediverse.domain}/${notifications.data[0].account.id}">
|
||||
${notifications.data[0].account.acct}</a></b>
|
||||
`<b><a href="${config.fediverse.domain}/${events.data[0].account.id}">
|
||||
${events.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has followed you.</b></font>
|
||||
<br><i>${notifications.data[0].account.note}</i>`);
|
||||
} else if (notifications.data[0].type === 'favourite') {
|
||||
<br><i>${events.data[0].account.note}</i>`);
|
||||
} else if (events.data[0].type === 'favourite') {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b><a href="${registrar.config.fediverse.domain}/${notifications.data[0].account.id}">
|
||||
${notifications.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">favorited</a>
|
||||
`<b><a href="${config.fediverse.domain}/${events.data[0].account.id}">
|
||||
${events.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${events.data[0].status.uri}">favorited</a>
|
||||
your post:</b></font>
|
||||
<br><blockquote><i><b>${notifications.data[0].status.content}</i></b></blockquote>`);
|
||||
} else if (notifications.data[0].type === 'mention') {
|
||||
<br><blockquote><i><b>${events.data[0].status.content}</i></b></blockquote>`);
|
||||
} else if (events.data[0].type === 'mention') {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b><a href="${registrar.config.fediverse.domain}/${notifications.data[0].account.id}">
|
||||
${notifications.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">mentioned</a>
|
||||
you:</b></font><br><blockquote><i><b>${notifications.data[0].status.content}
|
||||
<br>(id: ${notifications.data[0].status.id}) ${registrar.media.visibilityEmoji(notifications.data[0].status.visibility)}</i></b>
|
||||
`<b><a href="${config.fediverse.domain}/${events.data[0].account.id}">
|
||||
${events.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${events.data[0].status.uri}">mentioned</a>
|
||||
you:</b></font><br><blockquote><i><b>${events.data[0].status.content}
|
||||
<br>(id: ${events.data[0].status.id}) ${registrar.media.visibilityEmoji(events.data[0].status.visibility)}</i></b>
|
||||
</blockquote>`);
|
||||
} else if (notifications.data[0].type === 'reblog') {
|
||||
} else if (events.data[0].type === 'reblog') {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b><a href="${registrar.config.fediverse.domain}/${notifications.data[0].account.id}">
|
||||
${notifications.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">repeated</a>
|
||||
`<b><a href="${config.fediverse.domain}/${events.data[0].account.id}">
|
||||
${events.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${events.data[0].status.uri}">repeated</a>
|
||||
your post:</b></font><br>
|
||||
<blockquote><i><b>${notifications.data[0].status.content}</i></b></blockquote>`);
|
||||
<blockquote><i><b>${events.data[0].status.content}</i></b></blockquote>`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}/pin`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses/${userInput}/pin`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`Pinned:
|
||||
<blockquote><i><a href="${registrar.config.fediverse.domain}/notice/${response.data.id}">
|
||||
<blockquote><i><a href="${config.fediverse.domain}/notice/${response.data.id}">
|
||||
${response.data.content}</a></i>
|
||||
</blockquote>`);
|
||||
})
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
data: { status: userInput, content_type: `text/markdown` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'DELETE',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses/${userInput}`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, address, flaggedInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, address, flaggedInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
data: { status: flaggedInput, in_reply_to_id: address, content_type: `text/markdown` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput, ) {
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses/${userInput}`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b><a href="${registrar.config.fediverse.domain}/notice/${response.data.id}">${response.data.account.acct}</a>
|
||||
`<b><a href="${config.fediverse.domain}/notice/${response.data.id}">${response.data.account.acct}</a>
|
||||
<blockquote><i>${response.data.content}<br>
|
||||
${response.data.media_attachments.map(media =>
|
||||
`<a href="${media.remote_url}"><b>${media.description}</b></a>`)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, address, flaggedInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, address, flaggedInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
data: { status: `@10grans@fedi.cc tip `+ flaggedInput + ` to `+address },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
axios.get(`${registrar.config.fediverse.domain}/api/v1/accounts/${userInput}`).then((findUID) => {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios.get(`${config.fediverse.domain}/api/v1/accounts/${userInput}`).then((findUID) => {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/accounts/${findUID.data.id}/unfollow`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
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>${registrar.config.fediverse.domain}/${response.data.id}`);
|
||||
<blockquote>${config.fediverse.domain}/${response.data.id}`);
|
||||
});
|
||||
}).catch((e) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
exports.runQuery = function (matrixClient, room, userInput) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}/unpin`,
|
||||
headers: { Authorization: `Bearer ${registrar.fediverse_auth.access_token}` },
|
||||
url: `${config.fediverse.domain}/api/v1/statuses/${userInput}/unpin`,
|
||||
headers: { Authorization: `Bearer ${fediverse_auth.access_token}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`Unpinned:
|
||||
<blockquote><i><a href="${registrar.config.fediverse.domain}/notice/${response.data.id}">
|
||||
<blockquote><i><a href="${config.fediverse.domain}/notice/${response.data.id}">
|
||||
${response.data.content}</a></i>
|
||||
</blockquote>`);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue