From 14afeae6e7e3fd099db162141df2453ebfad2d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=B5=E1=84=8E=E1=85=A1=E1=86=AB=E1=84=80?= =?UTF-8?q?=E1=85=B2?= Date: Mon, 2 Jan 2023 22:44:49 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B6=80=EC=84=9C,=20=EC=95=84?= =?UTF-8?q?=EB=B0=94=ED=83=80=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20default?= =?UTF-8?q?=EB=A1=9C=20=EB=84=A3=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env_sample | 1 + app/api/routers/users.py | 1 - app/domains/users/schemas.py | 8 +++++--- app/domains/users/services.py | 5 +++-- app/utils/slack_message_format.py | 8 ++++---- conf/settings.py | 4 ++++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.env_sample b/.env_sample index 9688e97..61cc870 100644 --- a/.env_sample +++ b/.env_sample @@ -23,3 +23,4 @@ ALLOWED_EMOJI_TYPES='[ ]' RANK_URL="" +#DEFAULT_AVATAR_URL="" diff --git a/app/api/routers/users.py b/app/api/routers/users.py index 450d289..66f6b51 100644 --- a/app/api/routers/users.py +++ b/app/api/routers/users.py @@ -8,7 +8,6 @@ from app.domains.users.schemas import UserCreateSchema from app.domains.users.entities import UserDetailInfo - user_router = APIRouter() diff --git a/app/domains/users/schemas.py b/app/domains/users/schemas.py index 047ec62..f83ca27 100644 --- a/app/domains/users/schemas.py +++ b/app/domains/users/schemas.py @@ -1,10 +1,12 @@ from typing import Optional -from pydantic import BaseModel +from pydantic import BaseModel, Field + +from conf import settings class UserCreateSchema(BaseModel): slack_id: str name: str - avatar_url: Optional[str] - department: Optional[str] + avatar_url: Optional[str] = Field(default=settings.config.DEFAULT_AVATAR_URL) + department: Optional[str] = Field(default="개그팀") diff --git a/app/domains/users/services.py b/app/domains/users/services.py index 49f3aaf..8fb1571 100644 --- a/app/domains/users/services.py +++ b/app/domains/users/services.py @@ -3,6 +3,7 @@ from app.domains.users.entities import User from app.domains.users.repositories import UserRepository +from conf import settings class UserService: @@ -33,8 +34,8 @@ async def create_user(cls, attr: dict): return await cls._user_repository().insert(User( username=attr.get('name'), slack_id=attr.get('slack_id'), - avatar_url=attr.get('avatar_url'), - department=attr.get('department'), + avatar_url=attr.get('avatar_url', settings.config.DEFAULT_AVATAR_URL), + department=attr.get('department', '개그팀'), )) @classmethod diff --git a/app/utils/slack_message_format.py b/app/utils/slack_message_format.py index 1e996dd..38d5742 100644 --- a/app/utils/slack_message_format.py +++ b/app/utils/slack_message_format.py @@ -28,7 +28,7 @@ def get_best_user_format(title: str, best_users: dict) -> list: "block_id": "section568", "text": { "type": "mrkdwn", - "text": f"이번 달 개그맨 보다 더 많은 웃음을 준 크루는?! *{best_users.get('🤣', '🙈')}*\n:kkkk: :기쁨:" + "text": f"이번 달 개그맨 보다 더 많은 웃음을 준 크루는?! *{best_users.get('🤣', '🙈')}*\n" }, "accessory": { "type": "image", @@ -41,7 +41,7 @@ def get_best_user_format(title: str, best_users: dict) -> list: "block_id": "section569", "text": { "type": "mrkdwn", - "text": f"이번 달 많은 크루를 도와준 천사 크루는?! *{best_users.get('🙏️', '🙈')}*\n:pray: :기도:" + "text": f"이번 달 많은 크루를 도와준 천사 크루는?! *{best_users.get('🙏️', '🙈')}*\n:pray:" }, "accessory": { "type": "image", @@ -55,7 +55,7 @@ def get_best_user_format(title: str, best_users: dict) -> list: "text": { "type": "mrkdwn", "text": f"이번 달 가장 많은 이슈를 처리해 준 크루는?! *{best_users.get('👍', '🙈')}*\n" - f":+1: :wow: :wonderfulk: :천재_개발자:" + f":+1:" }, "accessory": { "type": "image", @@ -68,7 +68,7 @@ def get_best_user_format(title: str, best_users: dict) -> list: "block_id": "section571", "text": { "type": "mrkdwn", - "text": f"이번 달 가장 많은 크루를 당황시킨 크루는?! *{best_users.get('👀️', '🙈')}*\n:eye_shaking:" + "text": f"이번 달 가장 많은 크루를 당황시킨 크루는?! *{best_users.get('👀️', '🙈')}*\n" }, "accessory": { "type": "image", diff --git a/conf/settings.py b/conf/settings.py index 3fb139e..6f13abc 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -27,6 +27,10 @@ class BaseConfig(BaseSettings): ALLOWED_EMOJI_TYPES: list = Field(env="ALLOWED_EMOJI_TYPES", default=[]) RANK_URL: str = Field(env="RANK_URL", default="") + DEFAULT_AVATAR_URL: str = Field( + env="DEFAULT_AVATAR_URL", + default="https://github.com/JAY-Chan9yu/heymoji/blob/master/frontend/src/assets/logos/heymoji.png?raw=true" + ) class Config: env_file = ".env"