Create an activity to go along with the post object.
This commit is contained in:
parent
b86f7fe33e
commit
1fbca4e112
1 changed files with 16 additions and 0 deletions
|
@ -123,4 +123,20 @@ const fs = require('node:fs/promises');
|
|||
await fs.mkdir(writeDir, {recursive: true});
|
||||
await fs.writeFile(writePath, JSON.stringify(postObj));
|
||||
console.log(`Post created successfully! ${writePath}`);
|
||||
const postActivity = {
|
||||
object: postObj,
|
||||
"@context": postObj["@context"],
|
||||
to: postObj.to,
|
||||
cc: postObj.cc,
|
||||
type: "Create",
|
||||
actor: postObj.attributedTo,
|
||||
id: `${postObj.id}/activity`,
|
||||
published: postObj.published
|
||||
};
|
||||
delete postActivity.object["@context"];
|
||||
const activityWriteDir = path.join(writeDir, postId);
|
||||
const activityWritePath = path.join(activityWriteDir, "activity.json");
|
||||
await fs.mkdir(activityWriteDir, {recursive: true});
|
||||
await fs.writeFile(activityWritePath, JSON.stringify(postActivity));
|
||||
console.log(`Activity created successfully! ${activityWritePath}`);
|
||||
})();
|
Loading…
Add table
Reference in a new issue