completionId: cgen-c6bc0203da95435489b851b7f28c816f
cgen-c6bc0203da95435489b851b7f28c816f
This commit is contained in:
parent
8784a14259
commit
e2391f8a92
1 changed files with 38 additions and 1 deletions
|
|
@ -100,8 +100,45 @@ export default async function handler(req: any, res: any) {
|
|||
return res.status(500).json({ error: error.message });
|
||||
}
|
||||
|
||||
const createdPost = data?.[0];
|
||||
|
||||
// Publish activity event for post creation
|
||||
try {
|
||||
await fetch("http://localhost:3000/api/activity/publish", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
actor_id: author_id,
|
||||
verb: "created",
|
||||
object_type: "post",
|
||||
object_id: createdPost?.id,
|
||||
metadata: {
|
||||
summary: `Posted to ${arm_affiliation}`,
|
||||
title: title.substring(0, 100),
|
||||
},
|
||||
}),
|
||||
}).catch((err) => console.error("Activity publish error:", err));
|
||||
} catch (error) {
|
||||
console.error("Failed to publish activity:", error);
|
||||
}
|
||||
|
||||
// Apply rewards for post creation
|
||||
try {
|
||||
await fetch("http://localhost:3000/api/rewards/apply", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
user_id: author_id,
|
||||
action: "post_created",
|
||||
amount: 25,
|
||||
}),
|
||||
}).catch((err) => console.error("Rewards apply error:", err));
|
||||
} catch (error) {
|
||||
console.error("Failed to apply rewards:", error);
|
||||
}
|
||||
|
||||
return res.status(201).json({
|
||||
post: data?.[0],
|
||||
post: createdPost,
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("[Community Posts API POST] Unexpected error:", error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue