Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
FIX - JB-120 register_* not returning the actual user data
Browse files Browse the repository at this point in the history
Signed-off-by: RaenonX <[email protected]>
  • Loading branch information
RaenonX committed Sep 23, 2020
1 parent 6f6ed23 commit 57e91ac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion extline/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def get_profile(self, uid: str, *, channel_model: Optional[ChannelModel] = None)

return self._core.get_profile(uid, timeout=1000)
except LineBotApiError as ex:
if ex.status_code == 404:
# 404 seems to be the legacy status code upon user not found
# 400 is the status code returned upon user not found (2020/09/23)
if ex.status_code in (404, 400):
return None

raise ex
Expand Down
Binary file modified locale/zh_TW/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locale/zh_TW/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-03 22:58-0500\n"
"POT-Creation-Date: 2020-09-23 10:32-0500\n"
"PO-Revision-Date: 2020-09-03 19:49-0500\n"
"Last-Translator: RaenonX JELLYCAT <[email protected]>\n"
"Language-Team: \n"
Expand Down
12 changes: 11 additions & 1 deletion mongodb/factory/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ def register_onplat(self, platform: Platform, user_token: str) -> RootUserRegist
return RootUserRegistrationResult(WriteOutcome.X_ON_CONN_ONPLAT, ex, model, outcome, user_reg_result)

if outcome == WriteOutcome.O_DATA_EXISTS:
# `model` may not be as same as the one returned from `self.insert_one_data()`
model = self.get_root_data_oid(model.id)
if not model:
raise ValueError(f"Data of root OID {model.id} not found while it should be found.")

return RootUserRegistrationResult(WriteOutcome.O_DATA_EXISTS, ex, model, outcome, user_reg_result)

return RootUserRegistrationResult(WriteOutcome.O_INSERTED, ex, model, outcome, user_reg_result)
Expand Down Expand Up @@ -224,11 +229,16 @@ def register_google(self, id_data: GoogleIdentityUserData) -> RootUserRegistrati
return RootUserRegistrationResult(WriteOutcome.X_ON_CONN_API, ex, model, outcome, user_reg_result)

if outcome == WriteOutcome.O_DATA_EXISTS:
# Updating the email per the documentation
# Updating the email per the Google Identity documentation
APIUserManager.update_many_async({APIUserModel.GoogleUid.key: id_data.uid,
APIUserModel.Email.key: {"$ne": id_data.email}},
{"$set": {APIUserModel.Email.key: id_data.email}})

# `model` may not be as same as the one returned from `self.insert_one_data()`
model = self.get_root_data_oid(model.id)
if not model:
raise ValueError(f"Data of root OID {model.id} not found while it should be found.")

return RootUserRegistrationResult(WriteOutcome.O_DATA_EXISTS, ex, model, outcome, user_reg_result)

return RootUserRegistrationResult(WriteOutcome.O_INSERTED, ex, model, outcome, user_reg_result)
Expand Down

0 comments on commit 57e91ac

Please sign in to comment.