Skip to content
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

FCM 준비 #77

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

FCM 준비 #77

wants to merge 6 commits into from

Conversation

pcjs156
Copy link
Collaborator

@pcjs156 pcjs156 commented May 2, 2023

다른건 다 되는데 private key 부분이 잘 안되네용,,
Pycharm에서 환경 변수 자동으로 넣어주는 기능을 써서 그런가,,?

@pcjs156 pcjs156 requested a review from sookcha May 2, 2023 07:59
@pcjs156 pcjs156 self-assigned this May 2, 2023
@@ -1,3 +1,5 @@
firebase-credential.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것은 지웁시다

_cred = {
"type": "service_account",
"project_id": "postona-6bfc9",
"private_key_id": os.environ.get('FIREBASE_PRIVATE_KEY_ID'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.env.template 에도 추가해주세요~

Comment on lines +27 to +28
resp = messaging.send(message)
return resp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit)

Suggested change
resp = messaging.send(message)
return resp
return messaging.send(message)

@strawberry.type
class Mutation:
@strawberry.mutation
def send_fcm(self, info: Info, token: str, title: str, body: str) -> None:
Copy link
Collaborator

@sookcha sookcha May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

알림 보내는 mutation 이 외부로 노출될 때, 우리가 내부적으로 FCM을 쓰는지 다른 방식을 쓰는지 알려줄 필요는 없으므로 이름을 바꾸면 좋을 것 같아요. 내부 구조를 노출하기 위해서가 아닌, 무엇을 하는 뮤테이션인지 설명하기 위해서요.

Suggested change
def send_fcm(self, info: Info, token: str, title: str, body: str) -> None:
def send_push_notification(self, info: Info, token: str, title: str, body: str) -> None:

@sookcha
Copy link
Collaborator

sookcha commented May 2, 2023

heroku 에 secret key base64 encode 시켜서 업데이트 해두었습니다.

"type": "service_account",
"project_id": "postona-6bfc9",
"private_key_id": os.environ.get('FIREBASE_PRIVATE_KEY_ID'),
"private_key": base64.decode(os.environ.get('FIREBASE_PRIVATE_KEY')),
Copy link
Collaborator

@sookcha sookcha May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"private_key": base64.decode(os.environ.get('FIREBASE_PRIVATE_KEY')),
"private_key": base64.b64decode(os.environ.get('FIREBASE_PRIVATE_KEY')).decode("UTF-8"),

base64.b64decode 메소드를 사용해야할듯. 그러면 bytearray 가 응답됨. 그걸 다시 UTF-8 로 decode해줘야 정상적인 string이 나옴.

그냥 base64.decode 는 두 번째 인자로 output 이 들어가고, 파일로 결과가 써짐

내가 직접 테스트 해본 결과 잘 동작해. 나는 환경변수를 .env 파일에 넣어두었어.
화면 캡처 2023-05-02 221527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants