Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions client/src/graphql/base-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ export enum EChatType {
Public = "PUBLIC",
}

export enum EMessageType {
Text = "TEXT",
}

export enum EUserRole {
Student = "STUDENT",
Teacher = "TEACHER",
Expand Down Expand Up @@ -137,20 +133,17 @@ export type Message = IBaseType &
createdAt: Scalars["DateTime"]["output"]
id: Scalars["Int"]["output"]
text: Scalars["String"]["output"]
type: EMessageType
updatedAt: Scalars["DateTime"]["output"]
user: User
}

export type MessageFiltersIn = {
chatId: Scalars["Int"]["input"]
type?: InputMaybe<EMessageType>
}

export type MessageIn = {
chatId: Scalars["Int"]["input"]
text: Scalars["String"]["input"]
type: EMessageType
}

export type MessageObjectNotFoundError = Message | ObjectNotFoundError
Expand Down
10 changes: 1 addition & 9 deletions client/src/graphql/fragments/messages.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@ export type Incremental<T> =
import * as Types from "../base-types"

import gql from "graphql-tag"
export type EMessageType = "TEXT"

export type MessageFieldsFragment = {
id: number
createdAt: string
text: string
type: Types.EMessageType
}
export type MessageFieldsFragment = { id: number; createdAt: string; text: string }

export const MessageFieldsFragmentDoc = gql`
fragment MessageFields on Message {
id
createdAt
text
type
}
`
1 change: 0 additions & 1 deletion client/src/graphql/fragments/messages.gql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ fragment MessageFields on Message {
id
createdAt
text
type
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import * as VueCompositionApi from "vue"
export type ReactiveFunction<TParam> = () => TParam
export type EChatType = "PRIVATE" | "PUBLIC"

export type EMessageType = "TEXT"

export type EUserRole = "STUDENT" | "TEACHER"

export type PrivateChatIn = {
Expand Down Expand Up @@ -55,7 +53,6 @@ export type CreatePrivateChatMutation = {
id: number
createdAt: string
text: string
type: Types.EMessageType
user: {
id: number
createdAt: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import * as VueCompositionApi from "vue"
export type ReactiveFunction<TParam> = () => TParam
export type EChatType = "PRIVATE" | "PUBLIC"

export type EMessageType = "TEXT"

export type EUserRole = "STUDENT" | "TEACHER"

export type PublicChatIn = {
Expand Down Expand Up @@ -56,7 +54,6 @@ export type CreatePublicChatMutation = {
id: number
createdAt: string
text: string
type: Types.EMessageType
user: {
id: number
createdAt: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ import { UserFieldsFragmentDoc } from "../../fragments/auth.generated"
import * as VueApolloComposable from "@vue/apollo-composable"
import * as VueCompositionApi from "vue"
export type ReactiveFunction<TParam> = () => TParam
export type EMessageType = "TEXT"

export type EUserRole = "STUDENT" | "TEACHER"

export type MessageIn = {
chatId: number
text: string
type: EMessageType
}

export type CreateMessageMutationVariables = Exact<{
Expand All @@ -32,7 +29,6 @@ export type CreateMessageMutation = {
id: number
createdAt: string
text: string
type: Types.EMessageType
user: {
id: number
createdAt: string
Expand Down
3 changes: 0 additions & 3 deletions client/src/graphql/queries/chats/me-chats.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export type ChatFiltersIn = {

export type EChatType = "PRIVATE" | "PUBLIC"

export type EMessageType = "TEXT"

export type EUserRole = "STUDENT" | "TEACHER"

export type MeChatsQueryVariables = Exact<{
Expand Down Expand Up @@ -63,7 +61,6 @@ export type MeChatsQuery = {
id: number
createdAt: string
text: string
type: Types.EMessageType
user: {
id: number
createdAt: string
Expand Down
4 changes: 0 additions & 4 deletions client/src/graphql/queries/messages/messages.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ export type BasePaginationIn = {
offset?: number | null | undefined
}

export type EMessageType = "TEXT"

export type EUserRole = "STUDENT" | "TEACHER"

export type MessageFiltersIn = {
chatId: number
type?: EMessageType | null | undefined
}

export type MessagesQueryVariables = Exact<{
Expand All @@ -37,7 +34,6 @@ export type MessagesQuery = {
id: number
createdAt: string
text: string
type: Types.EMessageType
user: {
id: number
createdAt: string
Expand Down
3 changes: 0 additions & 3 deletions client/src/graphql/subscriptions/events.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { UserFieldsFragmentDoc } from "../fragments/auth.generated"
import * as VueApolloComposable from "@vue/apollo-composable"
import * as VueCompositionApi from "vue"
export type ReactiveFunction<TParam> = () => TParam
export type EMessageType = "TEXT"

export type EUserRole = "STUDENT" | "TEACHER"

export type EventsSubscriptionVariables = Exact<{ [key: string]: never }>
Expand All @@ -22,7 +20,6 @@ export type EventsSubscription = {
id: number
createdAt: string
text: string
type: Types.EMessageType
user: {
id: number
createdAt: string
Expand Down
3 changes: 1 addition & 2 deletions client/src/stores/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { CreateMessageDocument } from "@/graphql/mutations/messages/create-messa
import { MessagesDocument } from "@/graphql/queries/messages/messages.generated"
import type { MessageFieldsFragment } from "@/graphql/fragments/messages.generated"
import type { UserFieldsFragment } from "@/graphql/fragments/auth.generated"
import { EMessageType } from "@/graphql/base-types"

export type MessageItem = MessageFieldsFragment & { user: UserFieldsFragment }

Expand Down Expand Up @@ -49,7 +48,7 @@ export const useMessageStore = defineStore("messages", () => {

const { data } = await apolloClient.mutate({
mutation: CreateMessageDocument,
variables: { input: { chatId: chatId.value, type: EMessageType.Text, text } },
variables: { input: { chatId: chatId.value, text } },
})

if (data === undefined || data === null || data.createMessage.__typename !== "Message") {
Expand Down
7 changes: 0 additions & 7 deletions server/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ enum EChatType {
PUBLIC
}

enum EMessageType {
TEXT
}

enum EUserRole {
STUDENT
TEACHER
Expand Down Expand Up @@ -113,17 +109,14 @@ type Message implements IBaseType & IUser & IChat {
user: User!
chat: Chat!
text: String!
type: EMessageType!
}

input MessageFiltersIn {
chatId: Int!
type: EMessageType
}

input MessageIn {
chatId: Int!
type: EMessageType!
text: String!
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""u_messages_type

Revision ID: 0704ea73d326
Revises: c5f6674663cc
Create Date: 2026-09-04 21:37:50.487133

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "0704ea73d326"
down_revision: Union[str, Sequence[str], None] = "c5f6674663cc"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("messages", "type")
# ### end Alembic commands ###


def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"messages",
sa.Column(
"type",
postgresql.ENUM("TEXT", name="messagetype"),
autoincrement=False,
nullable=False,
),
)
# ### end Alembic commands ###
2 changes: 0 additions & 2 deletions server/src/server/database/models/messages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, mapped_column

from ...enums.messages import MessageType
from ..connection import Base
from .auth import User
from .chats import Chat
Expand All @@ -13,4 +12,3 @@ class Message(Base):
chat_id: Mapped[int] = mapped_column(ForeignKey(Chat.id, ondelete="CASCADE"))
user_id: Mapped[int] = mapped_column(ForeignKey(User.id, ondelete="CASCADE"))
encrypted_text: Mapped[str]
type: Mapped[MessageType]
5 changes: 0 additions & 5 deletions server/src/server/enums/messages.py

This file was deleted.

1 change: 0 additions & 1 deletion server/src/server/graphql/schema/messages/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ async def create_message(
instance = await info.context.services.message_service.create(
user_id=info.context.current_user.id,
chat_id=input.chat_id,
type=input.type,
text=input.text,
)
await info.context.session.commit()
Expand Down
2 changes: 0 additions & 2 deletions server/src/server/graphql/types/messages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from .enums import EMessageType
from .inputs import MessageFiltersIn, MessageIn
from .types import Message, MessagesMeta

__all__ = (
"Message",
"EMessageType",
"MessagesMeta",
"MessageFiltersIn",
"MessageIn",
Expand Down
5 changes: 0 additions & 5 deletions server/src/server/graphql/types/messages/enums.py

This file was deleted.

10 changes: 1 addition & 9 deletions server/src/server/graphql/types/messages/inputs.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import strawberry

from ....services.messages.types import MessageGetListFilters
from .enums import EMessageType


@strawberry.input
class MessageFiltersIn:
chat_id: int
type: strawberry.Maybe[EMessageType]

def to_service_params(self) -> MessageGetListFilters:
params: MessageGetListFilters = {"chat_id": self.chat_id}

if self.type is not None:
params["type"] = self.type.value

return params
return MessageGetListFilters(chat_id=self.chat_id)


@strawberry.input
class MessageIn:
chat_id: int
type: EMessageType
text: str
3 changes: 0 additions & 3 deletions server/src/server/graphql/types/messages/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
from ..auth import IUser
from ..base import IBaseMeta, IBaseType
from ..chats import IChat
from .enums import EMessageType


@strawberry.type
class Message(IBaseType, IUser, IChat):
text: str
type: EMessageType

@classmethod
def from_schema(cls, instance: MessageResponse) -> Self:
Expand All @@ -21,7 +19,6 @@ def from_schema(cls, instance: MessageResponse) -> Self:
user_id=instance.user_id,
chat_id=instance.chat_id,
text=instance.text,
type=instance.type,
created_at=instance.created_at,
updated_at=instance.updated_at,
)
Expand Down
2 changes: 0 additions & 2 deletions server/src/server/scripts/seed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from ..database.models.chats import Chat, ChatParticipant
from ..database.models.messages import Message
from ..enums.chats import ChatType
from ..enums.messages import MessageType
from ..enums.users import UserRole

_TEST_DATA_PATH = Path(__file__).parent / "test_data.json"
Expand Down Expand Up @@ -83,7 +82,6 @@ async def _seed_messages(
chat_id=chats[chat_idx].id,
user_id=users[user_idx].id,
encrypted_text=fernet.encrypt(text.encode()).decode(),
type=MessageType.TEXT,
)
for chat_idx, user_idx, text in _MESSAGES_INDEXES
]
Expand Down
3 changes: 0 additions & 3 deletions server/src/server/services/messages/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
from cryptography.fernet import Fernet

from ...database.models.messages import Message
from ...enums.messages import MessageType
from ..base import BaseResponse


class MessageResponse(BaseResponse):
chat_id: int
user_id: int
type: MessageType
text: str

@classmethod
Expand All @@ -19,7 +17,6 @@ def from_ORM(cls, instance: Message, fernet: Fernet) -> Self:
id=instance.id,
chat_id=instance.chat_id,
user_id=instance.user_id,
type=instance.type,
text=fernet.decrypt(instance.encrypted_text.encode()).decode(),
created_at=instance.created_at,
updated_at=instance.updated_at,
Expand Down
Loading