mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +01:00
fix: export sendMessage as _sendMessage for use in ap jobs lib
This commit is contained in:
@@ -355,7 +355,7 @@ ActivityPub.get = async (type, id, uri, options) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function sendMessage(uri, id, type, payload) {
|
ActivityPub._sendMessage = async function (uri, id, type, payload) {
|
||||||
try {
|
try {
|
||||||
const keyData = await ActivityPub.getPrivateKey(type, id);
|
const keyData = await ActivityPub.getPrivateKey(type, id);
|
||||||
const headers = await ActivityPub.sign(keyData, uri, payload);
|
const headers = await ActivityPub.sign(keyData, uri, payload);
|
||||||
@@ -381,7 +381,7 @@ async function sendMessage(uri, id, type, payload) {
|
|||||||
ActivityPub.helpers.log(`[activitypub/send] Could not send ${payload.type} to ${uri}; error: ${e.message}`);
|
ActivityPub.helpers.log(`[activitypub/send] Could not send ${payload.type} to ${uri}; error: ${e.message}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
ActivityPub.send = async (type, id, targets, payload) => {
|
ActivityPub.send = async (type, id, targets, payload) => {
|
||||||
if (!meta.config.activitypubEnabled) {
|
if (!meta.config.activitypubEnabled) {
|
||||||
@@ -415,7 +415,7 @@ ActivityPub.send = async (type, id, targets, payload) => {
|
|||||||
const retryQueuedSet = [];
|
const retryQueuedSet = [];
|
||||||
|
|
||||||
await Promise.all(inboxBatch.map(async (uri) => {
|
await Promise.all(inboxBatch.map(async (uri) => {
|
||||||
const ok = await sendMessage(uri, id, type, payload);
|
const ok = await ActivityPub._sendMessage(uri, id, type, payload);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
const queueId = crypto.createHash('sha256').update(`${type}:${id}:${uri}`).digest('hex');
|
const queueId = crypto.createHash('sha256').update(`${type}:${id}:${uri}`).digest('hex');
|
||||||
const nextTryOn = Date.now() + oneMinute;
|
const nextTryOn = Date.now() + oneMinute;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ async function retryFailedMessages() {
|
|||||||
queueIdsToRemove.push(queueId);
|
queueIdsToRemove.push(queueId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ok = await sendMessage(uri, id, type, payloadObj);
|
const ok = await activitypub._sendMessage(uri, id, type, payloadObj);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
queueIdsToRemove.push(queueId);
|
queueIdsToRemove.push(queueId);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user