16 lines
468 B
TypeScript
16 lines
468 B
TypeScript
import "server-only";
|
|
|
|
import { getRedisClient, redisEventChannel } from "@/lib/redis/client";
|
|
|
|
export async function notifyCommentChange(target: string) {
|
|
try {
|
|
const redis = await getRedisClient();
|
|
await Promise.all([
|
|
redis.publish(redisEventChannel(`comments:${target}`), "changed"),
|
|
redis.publish(redisEventChannel("comments:admin"), "changed"),
|
|
]);
|
|
} catch {
|
|
// A committed comment remains saved when Pub/Sub is unavailable.
|
|
}
|
|
}
|