presence service interface fix
This commit is contained in:
parent
34e6a03a89
commit
823b3c56c1
|
@ -1,12 +1,16 @@
|
||||||
import json
|
import json
|
||||||
from orm.reaction import Reaction
|
from orm.reaction import Reaction
|
||||||
from orm.shout import Shout
|
from orm.shout import Shout
|
||||||
|
from orm.user import Author
|
||||||
from services.redis import redis
|
from services.redis import redis
|
||||||
|
|
||||||
|
|
||||||
async def notify_reaction(reaction: Reaction):
|
async def notify_reaction(reaction: Reaction):
|
||||||
channel_name = f"new_reaction"
|
channel_name = "new_reaction"
|
||||||
data = {**reaction, "kind": f"new_reaction{reaction.kind}"}
|
data = {
|
||||||
|
"payload": reaction,
|
||||||
|
"kind": f"new_reaction{reaction.kind}"
|
||||||
|
}
|
||||||
try:
|
try:
|
||||||
await redis.publish(channel_name, json.dumps(data))
|
await redis.publish(channel_name, json.dumps(data))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -14,19 +18,21 @@ async def notify_reaction(reaction: Reaction):
|
||||||
|
|
||||||
|
|
||||||
async def notify_shout(shout: Shout):
|
async def notify_shout(shout: Shout):
|
||||||
channel_name = f"new_shout"
|
channel_name = "new_shout"
|
||||||
data = {**shout, "kind": "new_shout"}
|
data = {
|
||||||
|
"payload": shout,
|
||||||
|
"kind": "new_shout"
|
||||||
|
}
|
||||||
try:
|
try:
|
||||||
await redis.publish(channel_name, json.dumps(data))
|
await redis.publish(channel_name, json.dumps(data))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to publish to channel {channel_name}: {e}")
|
print(f"Failed to publish to channel {channel_name}: {e}")
|
||||||
|
|
||||||
|
|
||||||
async def notify_follower(follower_id: int, author_id: int):
|
async def notify_follower(follower: Author, author_id: int):
|
||||||
channel_name = f"new_follower"
|
channel_name = f"followers:{author_id}"
|
||||||
data = {
|
data = {
|
||||||
"follower_id": follower_id,
|
"payload": follower,
|
||||||
"author_id": author_id,
|
|
||||||
"kind": "new_follower",
|
"kind": "new_follower",
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user