-
Notifications
You must be signed in to change notification settings - Fork 0
feat: ユーザーアイコン(user_icon)をプロトコル・モデルに追加 #178
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
Merged
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -100,14 +100,17 @@ async def disconnect(self, close_code): | |
| await self.leave_party() | ||
|
|
||
| @action() | ||
| async def create(self, part_id, user_name, title="", **kwargs): | ||
| async def create( | ||
| self, part_id, user_name, title="", user_icon="FaRegUser", **kwargs | ||
| ): | ||
| # create room | ||
| self.anime_room = await self.database_create_room(part_id=part_id, title=title) | ||
| # create user | ||
| self.anime_user = await self.database_create_user( | ||
| user_name=user_name, | ||
| room_id=self.anime_room, | ||
| is_host=True, | ||
| user_icon=user_icon, | ||
| ) | ||
| await self.channel_layer.group_add( | ||
| str(self.anime_room.room_id), self.channel_name | ||
|
|
@@ -127,13 +130,16 @@ async def create(self, part_id, user_name, title="", **kwargs): | |
| ) | ||
|
|
||
| @action() | ||
| async def join(self, room_id: uuid, user_name: str, **kwargs): | ||
| async def join( | ||
| self, room_id: uuid, user_name: str, user_icon="FaRegUser", **kwargs | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [mypy] reported by reviewdog 🐶 |
||
| ): | ||
| """joinを受け取った場合のアクション | ||
| joinを受け取った場合、ルームが存在していればルームに参加する | ||
|
|
||
| Args: | ||
| room_id (uuid): AnimeRoomオブジェクトに存在するroom_id | ||
| user_name (str): ユーザーが指定する事ができるユーザー名 | ||
| user_icon (str): ユーザーが指定する react-icons (FA6) のキー。旧拡張は送らないため既定値あり。 | ||
| """ | ||
| # 接続要求されたルームのオブジェクトがあれば取得(deleted_at が入っているものは弾く) | ||
| self.anime_room = await self.database_get_or_none_room(room_id=room_id) | ||
|
|
@@ -150,7 +156,7 @@ async def join(self, room_id: uuid, user_name: str, **kwargs): | |
| _cancel_pending_room_delete(str(self.anime_room.room_id)) | ||
| # ルームが存在しているのであればAnimeUserオブジェクトを作成 | ||
| self.anime_user = await self.database_create_user( | ||
| user_name=user_name, room_id=self.anime_room | ||
| user_name=user_name, room_id=self.anime_room, user_icon=user_icon | ||
| ) | ||
| await self.channel_layer.group_add( | ||
| str(self.anime_room.room_id), self.channel_name | ||
|
|
@@ -427,19 +433,26 @@ async def leave_party(self): | |
|
|
||
| # control database | ||
| @database_sync_to_async | ||
| def database_create_user(self, user_name: str, room_id, is_host: bool = False): | ||
| def database_create_user( | ||
| self, | ||
| user_name: str, | ||
| room_id, | ||
| is_host: bool = False, | ||
| user_icon: str = "FaRegUser", | ||
| ): | ||
| """データベース上にユーザーを作成する | ||
|
|
||
| Args: | ||
| user_name ([type]): ユーザーが任意に指定可能な名前 | ||
| room_id ([type]): AnimeRoomに存在するID | ||
| is_host (bool, optional): ホストユーザーの場合はTrueにする | ||
| user_icon (str, optional): react-icons (FA6) のキー。未指定なら既定アイコン。 | ||
|
|
||
| Returns: | ||
| AnimeUser : 作成したユーザーのオブジェクト | ||
| """ | ||
| return AnimeUser.objects.create( | ||
| user_name=user_name, room_id=room_id, is_host=is_host | ||
| user_name=user_name, room_id=room_id, is_host=is_host, user_icon=user_icon | ||
| ) | ||
|
|
||
| @database_sync_to_async | ||
|
|
@@ -553,7 +566,9 @@ def database_renew_state(self): | |
| def database_user_list(self): | ||
| """ルーム内のユーザーを取得する""" | ||
| ar = AnimeRoom.objects.get(room_id=self.anime_room.room_id) | ||
| user_list = ar.inroom.alive().values("user_name", "user_id", "is_host") | ||
| user_list = ar.inroom.alive().values( | ||
| "user_name", "user_id", "is_host", "user_icon" | ||
| ) | ||
| return list(user_list) | ||
|
|
||
| @database_sync_to_async | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [mypy] reported by reviewdog 🐶
Module "uuid" is not valid as a type [valid-type]