Handle delivered JSONs as opaque objects to remove the need for repeated serialization
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
This commit is contained in:
parent
dc058741d1
commit
c9feae3a28
|
@ -169,7 +169,7 @@ export async function magApGet(userId: string, url: string): Promise<any> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function magApPost(userId: string, url: string, body: any): Promise<any> {
|
export async function magApPost(userId: string, url: string, body: string): Promise<any> {
|
||||||
logger.debug(`AP POST to: ${url}`);
|
logger.debug(`AP POST to: ${url}`);
|
||||||
return await rpcCall("/ap/post", {
|
return await rpcCall("/ap/post", {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
|
|
|
@ -18,14 +18,14 @@ import {endedPollNotification} from "./processors/ended-poll-notification.js";
|
||||||
import {queueLogger} from "./logger.js";
|
import {queueLogger} from "./logger.js";
|
||||||
import {getJobInfo} from "./get-job-info.js";
|
import {getJobInfo} from "./get-job-info.js";
|
||||||
import {
|
import {
|
||||||
backgroundQueue,
|
backgroundQueue,
|
||||||
dbQueue,
|
dbQueue,
|
||||||
deliverQueue,
|
deliverQueue,
|
||||||
endedPollNotificationQueue,
|
endedPollNotificationQueue,
|
||||||
inboxQueue,
|
inboxQueue,
|
||||||
objectStorageQueue,
|
objectStorageQueue,
|
||||||
systemQueue,
|
systemQueue,
|
||||||
webhookDeliverQueue,
|
webhookDeliverQueue,
|
||||||
} from "./queues.js";
|
} from "./queues.js";
|
||||||
import type {ThinUser} from "./types.js";
|
import type {ThinUser} from "./types.js";
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ export function deliver(user: ThinUser, content: unknown, to: string | null) {
|
||||||
user: {
|
user: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
},
|
},
|
||||||
content,
|
content: JSON.stringify(content, null, 2),
|
||||||
to,
|
to,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@ import type Bull from "bull";
|
||||||
|
|
||||||
const logger = new Logger("deliver");
|
const logger = new Logger("deliver");
|
||||||
|
|
||||||
let latest: string | null = null;
|
|
||||||
|
|
||||||
export default async (job: Bull.Job<DeliverJobData>) => {
|
export default async (job: Bull.Job<DeliverJobData>) => {
|
||||||
let host: string;
|
let host: string;
|
||||||
try {
|
try {
|
||||||
|
@ -29,10 +27,6 @@ export default async (job: Bull.Job<DeliverJobData>) => {
|
||||||
if (await shouldSkipInstance(puny)) return "skip";
|
if (await shouldSkipInstance(puny)) return "skip";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (latest !== (latest = JSON.stringify(job.data.content, null, 2))) {
|
|
||||||
logger.debug(`delivering ${latest}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await request(job.data.user, job.data.to, job.data.content);
|
await request(job.data.user, job.data.to, job.data.content);
|
||||||
|
|
||||||
// Update stats
|
// Update stats
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import type { DriveFile } from "@/models/entities/drive-file.js";
|
import type {DriveFile} from "@/models/entities/drive-file.js";
|
||||||
import type { Note } from "@/models/entities/note";
|
import type {Note} from "@/models/entities/note";
|
||||||
import type { User } from "@/models/entities/user.js";
|
import type {User} from "@/models/entities/user.js";
|
||||||
import type { Webhook } from "@/models/entities/webhook";
|
import type {Webhook} from "@/models/entities/webhook";
|
||||||
import type { IActivity } from "@/remote/activitypub/type.js";
|
import type {IActivity} from "@/remote/activitypub/type.js";
|
||||||
import type httpSignature from "@peertube/http-signature";
|
import type httpSignature from "@peertube/http-signature";
|
||||||
|
|
||||||
export type DeliverJobData = {
|
export type DeliverJobData = {
|
||||||
/** Actor */
|
/** Actor */
|
||||||
user: ThinUser;
|
user: ThinUser;
|
||||||
/** Activity */
|
/** Activity */
|
||||||
content: unknown;
|
content: string;
|
||||||
/** inbox URL to deliver */
|
/** inbox URL to deliver */
|
||||||
to: string;
|
to: string;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type {User} from "@/models/entities/user.js";
|
import type {User} from "@/models/entities/user.js";
|
||||||
import {magApGet, magApPost} from "@/mag/rpc-client.js";
|
import {magApGet, magApPost} from "@/mag/rpc-client.js";
|
||||||
|
|
||||||
export default async (user: { id: User["id"] }, url: string, body: any) => {
|
export default async (user: { id: User["id"] }, url: string, body: string) => {
|
||||||
return await magApPost(user.id, url, body);
|
return await magApPost(user.id, url, body);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue