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

Commit 57e91ac

Browse files
committed
FIX - JB-120 register_* not returning the actual user data
Signed-off-by: RaenonX <[email protected]>
1 parent 6f6ed23 commit 57e91ac

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

extline/wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def get_profile(self, uid: str, *, channel_model: Optional[ChannelModel] = None)
9494

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

100102
raise ex

locale/zh_TW/LC_MESSAGES/django.mo

0 Bytes
Binary file not shown.

locale/zh_TW/LC_MESSAGES/django.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: 1.0.0\n"
88
"Report-Msgid-Bugs-To: \n"
9-
"POT-Creation-Date: 2020-09-03 22:58-0500\n"
9+
"POT-Creation-Date: 2020-09-23 10:32-0500\n"
1010
"PO-Revision-Date: 2020-09-03 19:49-0500\n"
1111
"Last-Translator: RaenonX JELLYCAT <[email protected]>\n"
1212
"Language-Team: \n"

mongodb/factory/user.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ def register_onplat(self, platform: Platform, user_token: str) -> RootUserRegist
196196
return RootUserRegistrationResult(WriteOutcome.X_ON_CONN_ONPLAT, ex, model, outcome, user_reg_result)
197197

198198
if outcome == WriteOutcome.O_DATA_EXISTS:
199+
# `model` may not be as same as the one returned from `self.insert_one_data()`
200+
model = self.get_root_data_oid(model.id)
201+
if not model:
202+
raise ValueError(f"Data of root OID {model.id} not found while it should be found.")
203+
199204
return RootUserRegistrationResult(WriteOutcome.O_DATA_EXISTS, ex, model, outcome, user_reg_result)
200205

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

226231
if outcome == WriteOutcome.O_DATA_EXISTS:
227-
# Updating the email per the documentation
232+
# Updating the email per the Google Identity documentation
228233
APIUserManager.update_many_async({APIUserModel.GoogleUid.key: id_data.uid,
229234
APIUserModel.Email.key: {"$ne": id_data.email}},
230235
{"$set": {APIUserModel.Email.key: id_data.email}})
231236

237+
# `model` may not be as same as the one returned from `self.insert_one_data()`
238+
model = self.get_root_data_oid(model.id)
239+
if not model:
240+
raise ValueError(f"Data of root OID {model.id} not found while it should be found.")
241+
232242
return RootUserRegistrationResult(WriteOutcome.O_DATA_EXISTS, ex, model, outcome, user_reg_result)
233243

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

0 commit comments

Comments
 (0)