createdby-fix
This commit is contained in:
parent
685988c219
commit
1362eaa125
|
@ -1,7 +1,9 @@
|
||||||
[0.2.17]
|
[0.2.17]
|
||||||
- schema: enum types workaround, ReactionKind, InviteStatus, ShoutVisibility
|
- schema: enum types workaround, ReactionKind, InviteStatus, ShoutVisibility
|
||||||
|
- schema: Shout.created_by, Shout.updated_by fixes
|
||||||
- resovlers: optimized reacted shouts updates query
|
- resovlers: optimized reacted shouts updates query
|
||||||
|
|
||||||
|
|
||||||
[0.2.16]
|
[0.2.16]
|
||||||
- resolvers: collab inviting logics
|
- resolvers: collab inviting logics
|
||||||
- resolvers: queries and mutations revision and renaming
|
- resolvers: queries and mutations revision and renaming
|
||||||
|
|
|
@ -24,7 +24,7 @@ class User(Base):
|
||||||
# preferred_username = Column(String, nullable=False)
|
# preferred_username = Column(String, nullable=False)
|
||||||
picture = Column(String)
|
picture = Column(String)
|
||||||
revoked_timestamp = Column(Integer)
|
revoked_timestamp = Column(Integer)
|
||||||
roles = Column(JSON)
|
roles = Column(String, default="author, reader")
|
||||||
signup_methods = Column(String, default="magic_link_login")
|
signup_methods = Column(String, default="magic_link_login")
|
||||||
created_at = Column(Integer, default=lambda: int(time.time()))
|
created_at = Column(Integer, default=lambda: int(time.time()))
|
||||||
updated_at = Column(Integer, default=lambda: int(time.time()))
|
updated_at = Column(Integer, default=lambda: int(time.time()))
|
||||||
|
|
|
@ -64,7 +64,7 @@ async def create_invite(_, info, slug: str = "", author_id: int = None):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
shout = session.query(Shout).filter(Shout.slug == slug).first()
|
shout = session.query(Shout).filter(Shout.slug == slug).first()
|
||||||
inviter = session.query(Author).filter(Author.user == user_id).first()
|
inviter = session.query(Author).filter(Author.user == user_id).first()
|
||||||
if inviter and shout and shout.authors and inviter.id == shout.authors[0]:
|
if inviter and shout and shout.authors and inviter.id == shout.created_by:
|
||||||
# Check if the author is a valid author
|
# Check if the author is a valid author
|
||||||
author = session.query(Author).filter(Author.id == author_id).first()
|
author = session.query(Author).filter(Author.id == author_id).first()
|
||||||
if author:
|
if author:
|
||||||
|
@ -105,7 +105,7 @@ async def remove_author(_, info, slug: str = "", author_id: int = None):
|
||||||
if author:
|
if author:
|
||||||
shout = session.query(Shout).filter(Shout.slug == slug).first()
|
shout = session.query(Shout).filter(Shout.slug == slug).first()
|
||||||
# NOTE: owner should be first in a list
|
# NOTE: owner should be first in a list
|
||||||
if shout and author.id == shout.authors[0]:
|
if shout and author.id == shout.created_by:
|
||||||
shout.authors = [author for author in shout.authors if author.id != author_id]
|
shout.authors = [author for author in shout.authors if author.id != author_id]
|
||||||
session.commit()
|
session.commit()
|
||||||
return {}
|
return {}
|
||||||
|
@ -125,7 +125,7 @@ async def remove_invite(_, info, invite_id: int):
|
||||||
invite = session.query(Invite).filter(Invite.id == invite_id).first()
|
invite = session.query(Invite).filter(Invite.id == invite_id).first()
|
||||||
shout = session.query(Shout).filter(Shout.id == invite.shout_id).first()
|
shout = session.query(Shout).filter(Shout.id == invite.shout_id).first()
|
||||||
if shout and shout.deleted_at is None and invite:
|
if shout and shout.deleted_at is None and invite:
|
||||||
if invite.inviter_id == author.id or author.id == shout.authors.index(0):
|
if invite.inviter_id == author.id or author.id == shout.created_by:
|
||||||
if invite.status == InviteStatus.PENDING.value:
|
if invite.status == InviteStatus.PENDING.value:
|
||||||
# Delete the invite
|
# Delete the invite
|
||||||
session.delete(invite)
|
session.delete(invite)
|
||||||
|
|
|
@ -201,6 +201,7 @@ async def load_shouts_feed(_, info, options):
|
||||||
q = (
|
q = (
|
||||||
select(Shout)
|
select(Shout)
|
||||||
.options(
|
.options(
|
||||||
|
joinedload(Shout.created_by, Author.id == Shout.created_by),
|
||||||
joinedload(Shout.authors),
|
joinedload(Shout.authors),
|
||||||
joinedload(Shout.topics),
|
joinedload(Shout.topics),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user