fixzine
This commit is contained in:
parent
cf020f8f3e
commit
7d75480217
|
@ -45,7 +45,7 @@ def migrate(entry):
|
|||
with local_session() as session:
|
||||
shout = session.query(Shout).filter(Shout.old_id == entry['_id']).first()
|
||||
if not shout: shout = session.query(Shout).first()
|
||||
author = session.query(User).filter(User.old_id == entry['_id']).first()
|
||||
author = session.query(User).filter(User.old_id == entry['_id']).first() # FIXME
|
||||
comment_dict = {
|
||||
'old_id': entry['_id'],
|
||||
'author': author.id if author else 0,
|
||||
|
|
|
@ -10,7 +10,8 @@ from orm.base import Base
|
|||
class Message(Base):
|
||||
__tablename__ = 'message'
|
||||
|
||||
author: int = Column(ForeignKey("user.id"), nullable=False, comment="Sender")
|
||||
fromUser: int = Column(ForeignKey("user.id"), nullable=False, comment="Sender")
|
||||
chatRoom: int = Column(Integer, nullable=false, comment="Chatroom")
|
||||
body: str = Column(String, nullable=False, comment="Body")
|
||||
createdAt = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
||||
updatedAt = Column(DateTime, nullable=True, comment="Updated at")
|
||||
|
|
|
@ -14,7 +14,6 @@ from datetime import datetime, timedelta
|
|||
from pathlib import Path
|
||||
from sqlalchemy import select, func, desc, and_
|
||||
from sqlalchemy.orm import selectinload
|
||||
import pprint
|
||||
|
||||
|
||||
class GitTask:
|
||||
|
@ -353,7 +352,7 @@ async def view_shout(_, info, shout_id):
|
|||
@query.field("getShoutBySlug")
|
||||
async def get_shout_by_slug(_, info, slug):
|
||||
all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]
|
||||
pprint(all_fields)
|
||||
print(all_fields)
|
||||
selected_fields = set(["authors", "comments", "topics"]).intersection(all_fields)
|
||||
select_options = [selectinload(getattr(Shout, field)) for field in selected_fields]
|
||||
|
||||
|
|
|
@ -68,10 +68,16 @@ type MessageWithStatus {
|
|||
message: Message!
|
||||
}
|
||||
|
||||
type ChatRoomResult {
|
||||
messages: [Message]!
|
||||
room: ChatRoom!
|
||||
}
|
||||
|
||||
################################### Mutation
|
||||
|
||||
type Mutation {
|
||||
# message
|
||||
getRoom(chatRoom: Int!): ChatRoomResult! # TODO: private rooms protection
|
||||
createMessage(body: String!, replyTo: Int): MessageResult!
|
||||
updateMessage(id: Int!, body: String!): MessageResult!
|
||||
deleteMessage(messageId: Int!): Result!
|
||||
|
@ -162,7 +168,7 @@ type Query {
|
|||
|
||||
type Subscription {
|
||||
messageChanged: MessageWithStatus!
|
||||
|
||||
chatUpdated: ChatRoomResult!
|
||||
onlineUpdated: [User!]!
|
||||
shoutUpdated: Shout!
|
||||
userUpdated: User!
|
||||
|
@ -237,6 +243,7 @@ type User {
|
|||
|
||||
type Message {
|
||||
author: Int!
|
||||
chatRoom: Int!
|
||||
body: String!
|
||||
createdAt: DateTime!
|
||||
id: Int!
|
||||
|
@ -245,6 +252,13 @@ type Message {
|
|||
visibleForUsers: [Int]!
|
||||
}
|
||||
|
||||
type ChatRoom {
|
||||
id: Int!
|
||||
createdAt: DateTime!
|
||||
updatedAt: DateTime!
|
||||
notes: String
|
||||
}
|
||||
|
||||
type Comment {
|
||||
id: Int!
|
||||
author: User!
|
||||
|
|
Loading…
Reference in New Issue
Block a user