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