attempt to fix mastodon post follow accept
This commit is contained in:
parent
c3d57ccbe8
commit
f256889224
|
@ -201,14 +201,14 @@ export const sendAccept = async (user: User, followId: string, follower: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
const payload = JSON.stringify(activity, null, 4);
|
const payload = JSON.stringify(activity, null, 4);
|
||||||
const hash = hashDigest(payload);
|
|
||||||
|
|
||||||
const init: RequestInit = { method: "POST", body: payload };
|
const init: RequestInit = { method: "POST", body: payload };
|
||||||
const init2 = { hash, privateKey: user.private_key, keyId: getKeyId(user.nickname) };
|
const init2 = { privateKey: user.private_key, keyId: getKeyId(user.nickname) };
|
||||||
|
|
||||||
const result = await signedFetch(inbox, init, init2);
|
const result = await signedFetch(inbox, init, init2);
|
||||||
console.log("response status:", result.status);
|
console.log("response status:", result.status);
|
||||||
console.log("body:", result.body);
|
const response = streamToString(result.body as ReadableStream);
|
||||||
|
console.log("body:", response);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendAll = async (keyId: string, privateKey: string, activity: Record<string, any> | string, inboxes: string[]) => {
|
export const sendAll = async (keyId: string, privateKey: string, activity: Record<string, any> | string, inboxes: string[]) => {
|
||||||
|
|
|
@ -46,9 +46,9 @@ export const signedFetch = async (url: string, init: RequestInit, signedInit: Si
|
||||||
headers: signedHeaders
|
headers: signedHeaders
|
||||||
});
|
});
|
||||||
|
|
||||||
signedHeaders.push(["Signature", signature]);
|
|
||||||
|
|
||||||
const newHeaders = new Headers();
|
const newHeaders = new Headers();
|
||||||
|
newHeaders.set("Signature", signature);
|
||||||
|
|
||||||
if (Array.isArray(init.headers) || !init.headers) {
|
if (Array.isArray(init.headers) || !init.headers) {
|
||||||
for (const header of (init.headers || [])) {
|
for (const header of (init.headers || [])) {
|
||||||
if (Array.isArray(header))
|
if (Array.isArray(header))
|
||||||
|
@ -64,7 +64,10 @@ export const signedFetch = async (url: string, init: RequestInit, signedInit: Si
|
||||||
}
|
}
|
||||||
else throw "unsupported headers type"; // Lazy.
|
else throw "unsupported headers type"; // Lazy.
|
||||||
|
|
||||||
return fetch(url, init);
|
return fetch(url, {
|
||||||
|
...init,
|
||||||
|
headers: newHeaders
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getActor = async (actorUrl: string, signedInit: SignedInit): Promise<Actor | null> => {
|
export const getActor = async (actorUrl: string, signedInit: SignedInit): Promise<Actor | null> => {
|
||||||
|
|
Loading…
Reference in New Issue