Skip to content

Commit

Permalink
feat: 부서, 아바타 이미지 default로 넣도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JAY-Chan9yu committed Jan 2, 2023
1 parent 40d7e04 commit 14afeae
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions .env_sample
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ ALLOWED_EMOJI_TYPES='[
]'

RANK_URL=""
#DEFAULT_AVATAR_URL=""
1 change: 0 additions & 1 deletion app/api/routers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from app.domains.users.schemas import UserCreateSchema
from app.domains.users.entities import UserDetailInfo


user_router = APIRouter()


Expand Down
8 changes: 5 additions & 3 deletions app/domains/users/schemas.py
Original file line number Diff line number Diff line change
@@ -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="개그팀")
5 changes: 3 additions & 2 deletions app/domains/users/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from app.domains.users.entities import User
from app.domains.users.repositories import UserRepository
from conf import settings


class UserService:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/utils/slack_message_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 14afeae

Please sign in to comment.