create-reaction-unauthorized-handling
All checks were successful
Deploy on push / deploy (push) Successful in 26s
All checks were successful
Deploy on push / deploy (push) Successful in 26s
This commit is contained in:
parent
c80229b7b9
commit
0f5df77d28
|
@ -207,7 +207,8 @@ async def create_reaction(_, info, reaction):
|
||||||
info.context.get("user_id")
|
info.context.get("user_id")
|
||||||
author_id = info.context.get("author", {}).get("id")
|
author_id = info.context.get("author", {}).get("id")
|
||||||
shout_id = reaction.get("shout")
|
shout_id = reaction.get("shout")
|
||||||
|
if not author_id:
|
||||||
|
return {"error": "Unauthorized"}
|
||||||
if not shout_id:
|
if not shout_id:
|
||||||
return {"error": "Shout ID is required to create a reaction."}
|
return {"error": "Shout ID is required to create a reaction."}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,10 @@ REDIS_TTL = 86400 # 1 день в секундах
|
||||||
|
|
||||||
index_settings = {
|
index_settings = {
|
||||||
"settings": {
|
"settings": {
|
||||||
"index": {"number_of_shards": 1, "auto_expand_replicas": "0-all"},
|
"index": {
|
||||||
|
"number_of_shards": 1,
|
||||||
|
"auto_expand_replicas": "0-all"
|
||||||
|
},
|
||||||
"analysis": {
|
"analysis": {
|
||||||
"analyzer": {
|
"analyzer": {
|
||||||
"ru": {
|
"ru": {
|
||||||
|
@ -37,13 +40,13 @@ index_settings = {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"body": {"type": "text", "analyzer": "ru"},
|
"body": {"type": "text", "analyzer": "ru"},
|
||||||
#"cover": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
# "cover": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
#"created_at": {"type": "long"},
|
# "created_at": {"type": "long"},
|
||||||
#"created_by": {"type": "long"},
|
# "created_by": {"type": "long"},
|
||||||
#"featured_at": {"type": "long"},
|
# "featured_at": {"type": "long"},
|
||||||
#"id": {"type": "long"},
|
# "id": {"type": "long"},
|
||||||
#"lang": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
# "lang": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
#"layout": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
# "layout": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
"lead": {"type": "text", "analyzer": "ru"},
|
"lead": {"type": "text", "analyzer": "ru"},
|
||||||
"media": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
"media": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
# "oid": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
# "oid": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
|
|
|
@ -94,9 +94,8 @@ def after_reaction_update(mapper, connection, reaction: Reaction):
|
||||||
for author_with_stat in get_with_stat(author_query):
|
for author_with_stat in get_with_stat(author_query):
|
||||||
asyncio.create_task(cache_author(author_with_stat.dict()))
|
asyncio.create_task(cache_author(author_with_stat.dict()))
|
||||||
|
|
||||||
shout = connection.execute(
|
shout_query = select(Shout).select_from(Shout).where(Shout.id == reaction.shout)
|
||||||
select(Shout).select_from(Shout).where(Shout.id == reaction.shout)
|
[shout] = connection.execute(shout_query)
|
||||||
).first()
|
|
||||||
if shout:
|
if shout:
|
||||||
after_shout_update(mapper, connection, shout)
|
after_shout_update(mapper, connection, shout)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user