This commit is contained in:
@@ -4,26 +4,20 @@ from services.rediscache import redis
|
||||
|
||||
async def notify_reaction(reaction, action: str = "create"):
|
||||
channel_name = "reaction"
|
||||
data = {
|
||||
"payload": reaction,
|
||||
"action": action
|
||||
}
|
||||
data = {"payload": reaction, "action": action}
|
||||
try:
|
||||
await redis.publish(channel_name, json.dumps(data))
|
||||
except Exception as e:
|
||||
print(f"Failed to publish to channel {channel_name}: {e}")
|
||||
print(f"[services.notify] Failed to publish to channel {channel_name}: {e}")
|
||||
|
||||
|
||||
async def notify_shout(shout, action: str = "create"):
|
||||
channel_name = "shout"
|
||||
data = {
|
||||
"payload": shout,
|
||||
"action": action
|
||||
}
|
||||
data = {"payload": shout, "action": action}
|
||||
try:
|
||||
await redis.publish(channel_name, json.dumps(data))
|
||||
except Exception as e:
|
||||
print(f"Failed to publish to channel {channel_name}: {e}")
|
||||
print(f"[services.notify] Failed to publish to channel {channel_name}: {e}")
|
||||
|
||||
|
||||
async def notify_follower(follower: dict, author_id: int, action: str = "follow"):
|
||||
@@ -32,11 +26,8 @@ async def notify_follower(follower: dict, author_id: int, action: str = "follow"
|
||||
if k not in ["id", "name", "slug", "pic"]:
|
||||
del follower[k]
|
||||
channel_name = f"follower:{author_id}"
|
||||
data = {
|
||||
"payload": follower,
|
||||
"action": action
|
||||
}
|
||||
data = {"payload": follower, "action": action}
|
||||
try:
|
||||
await redis.publish(channel_name, json.dumps(data))
|
||||
except Exception as e:
|
||||
print(f"Failed to publish to channel {channel_name}: {e}")
|
||||
print(f"[services.notify] Failed to publish to channel {channel_name}: {e}")
|
||||
|
Reference in New Issue
Block a user