-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: new publisher for rooms infos
- Loading branch information
1 parent
a7ebf39
commit 367868d
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,9 @@ | ||
from dataclasses import dataclass | ||
from typing import List, Dict | ||
|
||
|
||
@dataclass | ||
class RoomDTO: | ||
project_uuid: str | ||
external_id: str | ||
created_on: str |
This file contains 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,17 @@ | ||
from django.conf import settings | ||
|
||
from chats.apps.event_driven.base_app import EventDrivenAPP | ||
|
||
|
||
class RoomsInfoMixin: | ||
base_room_exchange = settings.ROOMS_INFO_EXCHANGE | ||
|
||
def request_room(self, content): | ||
""" | ||
Generic function to handle room actions | ||
""" | ||
EventDrivenAPP().backend.basic_publish( | ||
content=content, | ||
exchange=self.base_room_exchange, | ||
headers={"callback_exchange": settings.DEFAULT_DEAD_LETTER_EXCHANGE}, | ||
) |
This file contains 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 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,16 @@ | ||
from chats.apps.api.v1.internal.eda_clients.billing_client import RoomsInfoMixin | ||
from chats.apps.api.v1.dto.room_dto import RoomDTO | ||
from chats.apps.rooms.models import Room | ||
|
||
|
||
class RoomInfoUseCase: | ||
def __init__(self): | ||
self._rooms_client = RoomsInfoMixin() | ||
|
||
def get_room(self, room: Room): | ||
room_dto = RoomDTO( | ||
project_uuid=room.project.uuid, | ||
external_id=room.contact.external_id, | ||
created_on=room.created_on, | ||
) | ||
self._rooms_client.request_room(content=room_dto) |
This file contains 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