-
-
Notifications
You must be signed in to change notification settings - Fork 76
CU-8687aj3gt Trying to fix User Push reg issue. #241
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -154,8 +154,13 @@ public async Task<ActionResult<PushRegistrationResult>> RegisterDevice([FromBody | |||||||||||||||||||||||||||||||||||||
| push.UserId = UserId; | ||||||||||||||||||||||||||||||||||||||
| push.PlatformType = registrationInput.Platform; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false); | ||||||||||||||||||||||||||||||||||||||
| push.PushLocation = department.Code; | ||||||||||||||||||||||||||||||||||||||
| if (!string.IsNullOrWhiteSpace(registrationInput.Prefix)) | ||||||||||||||||||||||||||||||||||||||
| push.PushLocation = registrationInput.Prefix; | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false); | ||||||||||||||||||||||||||||||||||||||
| push.PushLocation = department.Code; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+157
to
+163
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid NRE and guarantee non-empty PushLocation; trim Prefix and validate department fallback. If department is null (or Code empty) this throws, and PushService.Register rejects empty locations. Harden this block. - if (!string.IsNullOrWhiteSpace(registrationInput.Prefix))
- push.PushLocation = registrationInput.Prefix;
- else
- {
- var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);
- push.PushLocation = department.Code;
- }
+ if (!string.IsNullOrWhiteSpace(registrationInput.Prefix?.Trim()))
+ {
+ push.PushLocation = registrationInput.Prefix.Trim();
+ }
+ else
+ {
+ var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);
+ if (department == null || string.IsNullOrWhiteSpace(department.Code))
+ return BadRequest();
+ push.PushLocation = department.Code;
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| push.DeviceId = registrationInput.Token; | ||||||||||||||||||||||||||||||||||||||
| push.Uuid = registrationInput.DeviceUuid; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Good guard; align style and mirror DeviceId check in RegisterUnit.
string.IsNullOrWhiteSpaceconsistently.RegisterUnitshould also validateDeviceId.Also update RegisterUnit’s guard (outside this hunk) to include
DeviceId:🤖 Prompt for AI Agents