Merge branch 'drafts-2' into 'main'

slugs to ids, cover property added to ShoutInput

See merge request discoursio/discoursio-api!18
This commit is contained in:
Igor 2023-05-07 16:22:07 +00:00
commit 6068199c0f
2 changed files with 8 additions and 10 deletions

View File

@ -93,11 +93,11 @@ async def create_shout(_, info, inp):
@mutation.field("updateShout")
@login_required
async def update_shout(_, info, slug, inp):
async def update_shout(_, info, shout_id, shout_input):
auth: AuthCredentials = info.context["request"].auth
with local_session() as session:
shout = session.query(Shout).filter(Shout.slug == slug).first()
shout = session.query(Shout).filter(Shout.id == shout_id).first()
if not shout:
return {"error": "shout not found"}
@ -109,10 +109,10 @@ async def update_shout(_, info, slug, inp):
if Resource.shout not in scopes:
return {"error": "access denied"}
else:
shout.update(inp)
shout.update(shout_input)
shout.updatedAt = datetime.now(tz=timezone.utc)
if inp.get("topics"):
if shout_input.get("topics"):
# remove old links
links = session.query(ShoutTopic).where(ShoutTopic.shout == shout.id).all()
for topiclink in links:

View File

@ -103,9 +103,7 @@ input ShoutInput {
community: Int
mainTopic: String
subtitle: String
versionOf: String
visibleForRoles: [String] # role ids are strings
visibleForUsers: [String]
cover: String
}
input ProfileInput {
@ -170,9 +168,9 @@ type Mutation {
# shout
createShout(inp: ShoutInput!): Result!
updateShout(slug: String!, inp: ShoutInput!): Result!
deleteShout(slug: String!): Result!
publishShout(slug: String!, inp: ShoutInput!): Result!
updateShout(shout_id: Int!, shout_input: ShoutInput!): Result!
deleteShout(shout_id: Int!): Result!
publishShout(shout_id: Int!, shout_input: ShoutInput): Result!
# user profile
rateUser(slug: String!, value: Int!): Result!