This commit is contained in:
parent
167eed436d
commit
4e7250acef
|
@ -4,6 +4,7 @@
|
||||||
- services: cached elasticsearch connector
|
- services: cached elasticsearch connector
|
||||||
- services: auth is using user_id from authorizer
|
- services: auth is using user_id from authorizer
|
||||||
- resolvers: notify_* usage fixes
|
- resolvers: notify_* usage fixes
|
||||||
|
- resolvers: getAuthor now accepts slug, user_id or author_id
|
||||||
- resolvers: login_required usage fixes
|
- resolvers: login_required usage fixes
|
||||||
|
|
||||||
[0.2.14]
|
[0.2.14]
|
||||||
|
|
|
@ -138,8 +138,14 @@ async def get_authors_all(_, _info):
|
||||||
|
|
||||||
|
|
||||||
@query.field("getAuthor")
|
@query.field("getAuthor")
|
||||||
async def get_author(_, _info, slug):
|
async def get_author(_, _info, slug="", user=None, author=None):
|
||||||
|
if slug or user or author:
|
||||||
|
if slug:
|
||||||
q = select(Author).where(Author.slug == slug)
|
q = select(Author).where(Author.slug == slug)
|
||||||
|
elif user:
|
||||||
|
q = select(Author).where(Author.user == user)
|
||||||
|
elif author:
|
||||||
|
q = select(Author).where(Author.id == author)
|
||||||
q = add_author_stat_columns(q)
|
q = add_author_stat_columns(q)
|
||||||
|
|
||||||
authors = get_authors_from_query(q)
|
authors = get_authors_from_query(q)
|
||||||
|
|
|
@ -327,7 +327,7 @@ type Query {
|
||||||
authorFollowedAuthors(slug: String!): [Author]
|
authorFollowedAuthors(slug: String!): [Author]
|
||||||
authorFollowedTopics(slug: String!): [Topic]
|
authorFollowedTopics(slug: String!): [Topic]
|
||||||
loadAuthorsBy(by: AuthorsBy, limit: Int, offset: Int): [Author]
|
loadAuthorsBy(by: AuthorsBy, limit: Int, offset: Int): [Author]
|
||||||
getAuthor(slug: String!): Author
|
getAuthor(slug: String, user: String, author: Int): Author
|
||||||
|
|
||||||
topicsAll: [Topic]
|
topicsAll: [Topic]
|
||||||
getTopic(slug: String!): Topic
|
getTopic(slug: String!): Topic
|
||||||
|
|
|
@ -4,26 +4,20 @@ from services.rediscache import redis
|
||||||
|
|
||||||
async def notify_reaction(reaction, action: str = "create"):
|
async def notify_reaction(reaction, action: str = "create"):
|
||||||
channel_name = "reaction"
|
channel_name = "reaction"
|
||||||
data = {
|
data = {"payload": reaction, "action": action}
|
||||||
"payload": reaction,
|
|
||||||
"action": action
|
|
||||||
}
|
|
||||||
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"[services.notify] Failed to publish to channel {channel_name}: {e}")
|
||||||
|
|
||||||
|
|
||||||
async def notify_shout(shout, action: str = "create"):
|
async def notify_shout(shout, action: str = "create"):
|
||||||
channel_name = "shout"
|
channel_name = "shout"
|
||||||
data = {
|
data = {"payload": shout, "action": action}
|
||||||
"payload": shout,
|
|
||||||
"action": action
|
|
||||||
}
|
|
||||||
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"[services.notify] Failed to publish to channel {channel_name}: {e}")
|
||||||
|
|
||||||
|
|
||||||
async def notify_follower(follower: dict, author_id: int, action: str = "follow"):
|
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"]:
|
if k not in ["id", "name", "slug", "pic"]:
|
||||||
del follower[k]
|
del follower[k]
|
||||||
channel_name = f"follower:{author_id}"
|
channel_name = f"follower:{author_id}"
|
||||||
data = {
|
data = {"payload": follower, "action": action}
|
||||||
"payload": follower,
|
|
||||||
"action": action
|
|
||||||
}
|
|
||||||
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"[services.notify] Failed to publish to channel {channel_name}: {e}")
|
||||||
|
|
|
@ -12,7 +12,7 @@ class SearchService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def init(session):
|
async def init(session):
|
||||||
async with SearchService.lock:
|
async with SearchService.lock:
|
||||||
print("[search] did nothing")
|
print("[services.search] did nothing")
|
||||||
SearchService.cache = {}
|
SearchService.cache = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user