-
Notifications
You must be signed in to change notification settings - Fork 32
✨ First iteration backend for support center (🗃️) #8212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
matusdrobuliak66
merged 23 commits into
ITISFoundation:master
from
matusdrobuliak66:first-iteration-backend-for-support-center
Aug 18, 2025
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
425e498
first part
matusdrobuliak66 b202cf8
daily work
matusdrobuliak66 3faff0f
Handles support conversations without project ID
matusdrobuliak66 f119400
Splits message endpoints to dedicated controller
matusdrobuliak66 8a4675f
Refactors conversation endpoints for unified error handling
matusdrobuliak66 e513c15
Merge branch 'master' into first-iteration-backend-for-support-center
matusdrobuliak66 7eb1972
Adds support for extra context in conversations
matusdrobuliak66 23e81f7
Adds REST API endpoints for conversations and messages
matusdrobuliak66 460a21a
fix
matusdrobuliak66 5c1533a
Refactors conversation type argument naming for clarity
matusdrobuliak66 9d582b2
Clarifies API entrypoint section headers
matusdrobuliak66 877e4df
Renames parameter to avoid shadowing built-in type
matusdrobuliak66 470fbab
Fixes SQL filtering for conversation type matching
matusdrobuliak66 694770b
Improves error message for invalid conversation type
matusdrobuliak66 54c77fc
Adds support for SUPPORT conversation type and REST API tests
matusdrobuliak66 ea9ca85
add final tests
matusdrobuliak66 c1d8438
Merge branch 'master' into first-iteration-backend-for-support-center
matusdrobuliak66 9a36762
fix migration alembic version
matusdrobuliak66 d0cfbd2
Merge branch 'master' into first-iteration-backend-for-support-center
matusdrobuliak66 b6daa89
Merge branch 'master' into first-iteration-backend-for-support-center
matusdrobuliak66 083b377
Merge branch 'master' into first-iteration-backend-for-support-center
matusdrobuliak66 f65ce8b
Refactors conversation endpoints to use query helpers
matusdrobuliak66 8a31d1a
fix
matusdrobuliak66 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| """Helper script to automatically generate OAS | ||
|
|
||
| This OAS are the source of truth | ||
| """ | ||
|
|
||
| # pylint: disable=redefined-outer-name | ||
| # pylint: disable=unused-argument | ||
| # pylint: disable=unused-variable | ||
| # pylint: disable=too-many-arguments | ||
|
|
||
|
|
||
| from typing import Annotated | ||
|
|
||
| from _common import as_query | ||
| from fastapi import APIRouter, Depends, status | ||
| from models_library.api_schemas_webserver.conversations import ( | ||
| ConversationMessagePatch, | ||
| ConversationMessageRestGet, | ||
| ConversationPatch, | ||
| ConversationRestGet, | ||
| ) | ||
| from models_library.generics import Envelope | ||
| from models_library.rest_pagination import Page | ||
| from simcore_service_webserver._meta import API_VTAG | ||
| from simcore_service_webserver.conversations._controller._common import ( | ||
| ConversationPathParams, | ||
| ) | ||
| from simcore_service_webserver.conversations._controller._conversations_messages_rest import ( | ||
| _ConversationMessageCreateBodyParams, | ||
| _ConversationMessagePathParams, | ||
| _ListConversationMessageQueryParams, | ||
| ) | ||
| from simcore_service_webserver.conversations._controller._conversations_rest import ( | ||
| _ConversationsCreateBodyParams, | ||
| _GetConversationsQueryParams, | ||
| _ListConversationsQueryParams, | ||
| ) | ||
|
|
||
| router = APIRouter( | ||
| prefix=f"/{API_VTAG}", | ||
| tags=[ | ||
| "conversations", | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| # | ||
| # API entrypoints CONVERSATIONS | ||
| # | ||
|
|
||
|
|
||
| @router.post( | ||
| "/conversations", | ||
| response_model=Envelope[ConversationRestGet], | ||
| status_code=status.HTTP_201_CREATED, | ||
| ) | ||
| async def create_conversation( | ||
| _body: _ConversationsCreateBodyParams, | ||
| _query: Annotated[_GetConversationsQueryParams, Depends()], | ||
| ): ... | ||
|
|
||
|
|
||
| @router.get( | ||
| "/conversations", | ||
| response_model=Page[ConversationRestGet], | ||
| ) | ||
| async def list_conversations( | ||
| _query: Annotated[_ListConversationsQueryParams, Depends()], | ||
| ): ... | ||
|
|
||
|
|
||
| @router.put( | ||
| "/conversations/{conversation_id}", | ||
| response_model=Envelope[ConversationRestGet], | ||
| ) | ||
| async def update_conversation( | ||
| _params: Annotated[ConversationPathParams, Depends()], | ||
| _body: ConversationPatch, | ||
| _query: Annotated[as_query(_GetConversationsQueryParams), Depends()], | ||
| ): ... | ||
|
|
||
|
|
||
| @router.delete( | ||
| "/conversations/{conversation_id}", | ||
| status_code=status.HTTP_204_NO_CONTENT, | ||
| ) | ||
| async def delete_conversation( | ||
| _params: Annotated[ConversationPathParams, Depends()], | ||
| _query: Annotated[as_query(_GetConversationsQueryParams), Depends()], | ||
| ): ... | ||
|
|
||
|
|
||
| @router.get( | ||
| "/conversations/{conversation_id}", | ||
| response_model=Envelope[ConversationRestGet], | ||
| ) | ||
| async def get_conversation( | ||
| _params: Annotated[ConversationPathParams, Depends()], | ||
| _query: Annotated[as_query(_GetConversationsQueryParams), Depends()], | ||
| ): ... | ||
|
|
||
|
|
||
| # | ||
| # API entrypoints CONVERSATION MESSAGES | ||
| # | ||
|
|
||
|
|
||
| @router.post( | ||
| "/conversations/{conversation_id}/messages", | ||
| response_model=Envelope[ConversationMessageRestGet], | ||
| status_code=status.HTTP_201_CREATED, | ||
| ) | ||
| async def create_conversation_message( | ||
| _params: Annotated[ConversationPathParams, Depends()], | ||
| _body: _ConversationMessageCreateBodyParams, | ||
| ): ... | ||
|
|
||
|
|
||
| @router.get( | ||
| "/conversations/{conversation_id}/messages", | ||
| response_model=Page[ConversationMessageRestGet], | ||
| ) | ||
| async def list_conversation_messages( | ||
| _params: Annotated[ConversationPathParams, Depends()], | ||
| _query: Annotated[as_query(_ListConversationMessageQueryParams), Depends()], | ||
| ): ... | ||
|
|
||
|
|
||
| @router.put( | ||
| "/conversations/{conversation_id}/messages/{message_id}", | ||
| response_model=Envelope[ConversationMessageRestGet], | ||
| ) | ||
| async def update_conversation_message( | ||
| _params: Annotated[_ConversationMessagePathParams, Depends()], | ||
| _body: ConversationMessagePatch, | ||
| ): ... | ||
|
|
||
|
|
||
| @router.delete( | ||
| "/conversations/{conversation_id}/messages/{message_id}", | ||
| status_code=status.HTTP_204_NO_CONTENT, | ||
| ) | ||
| async def delete_conversation_message( | ||
| _params: Annotated[_ConversationMessagePathParams, Depends()], | ||
| ): ... | ||
|
|
||
|
|
||
| @router.get( | ||
| "/conversations/{conversation_id}/messages/{message_id}", | ||
| response_model=Envelope[ConversationMessageRestGet], | ||
| ) | ||
| async def get_conversation_message( | ||
| _params: Annotated[_ConversationMessagePathParams, Depends()], | ||
| ): ... | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ase/src/simcore_postgres_database/migration/versions/b566f1b29012_modify_conversations.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """modify conversations | ||
|
|
||
| Revision ID: b566f1b29012 | ||
| Revises: 5b998370916a | ||
| Create Date: 2025-08-14 15:02:54.784186+00:00 | ||
|
|
||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
| from sqlalchemy.dialects import postgresql | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "b566f1b29012" | ||
| down_revision = "5b998370916a" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.add_column( | ||
| "conversations", | ||
| sa.Column( | ||
| "extra_context", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| server_default=sa.text("'{}'::jsonb"), | ||
| nullable=False, | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "products", | ||
| sa.Column("support_standard_group_id", sa.BigInteger(), nullable=True), | ||
| ) | ||
| op.create_foreign_key( | ||
| "fk_products_support_standard_group_id", | ||
| "products", | ||
| "groups", | ||
| ["support_standard_group_id"], | ||
| ["gid"], | ||
| onupdate="CASCADE", | ||
| ondelete="SET NULL", | ||
| ) | ||
|
|
||
| op.execute( | ||
| """ | ||
| ALTER TYPE conversationtype ADD VALUE 'SUPPORT'; | ||
| """ | ||
| ) | ||
|
|
||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_constraint( | ||
| "fk_products_support_standard_group_id", "products", type_="foreignkey" | ||
| ) | ||
| op.drop_column("products", "support_standard_group_id") | ||
| op.drop_column("conversations", "extra_context") | ||
| # ### end Alembic commands ### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.