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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -9,7 +9,7 @@ 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