-
-
Notifications
You must be signed in to change notification settings - Fork 85
RG-T132 Push linking fix #473
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 |
|---|---|---|
|
|
@@ -712,16 +712,16 @@ public async Task<bool> SendChat(string chatId, int departmentId, string sending | |
| if (recipients.Count == 1) | ||
| { | ||
| var sendingTo = recipients.FirstOrDefault(); | ||
| spm.Id = $"T{sendingTo}"; | ||
|
|
||
| if (sendingTo == null) | ||
| return false; | ||
|
|
||
| spm.Id = $"T{sendingTo.UserId}"; | ||
|
|
||
| if (!await CanSendToUser(sendingTo.UserId, departmentId)) | ||
| return false; | ||
|
|
||
| if (sendingTo != null) | ||
| { | ||
| await _pushService.PushChat(spm, sendingTo.UserId, sendingTo); | ||
| } | ||
| await _pushService.PushChat(spm, sendingTo.UserId, sendingTo); | ||
|
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. Unhandled exception risk in Core/Resgrid.Services/CommunicationService.cs: awaiting _pushService.PushChat(spm, sendingTo.UserId, sendingTo) without error handling allows rejected push notifications to escape without an application-level outcome. Wrap the awaited call in try/catch so the method logs context and returns false instead of propagating the exception. Kody rule violation: Handle async operations with proper error handling try
{
await _pushService.PushChat(spm, sendingTo.UserId, sendingTo);
}
catch (Exception ex)
{
_logger.LogError(ex, "PushChat failed for user {UserId} in department {DepartmentId}", sendingTo.UserId, departmentId);
return false;
}Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. 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. Unhandled external service exception in Core/Resgrid.Services/CommunicationService.cs: _pushService.PushChat(spm, sendingTo.UserId, sendingTo) performs an external/service call that can throw transport or service errors without contextual handling. Wrap the awaited call in try/catch so the method logs user and department context and returns false instead of bubbling the exception. Kody rule violation: Add try-catch blocks for external calls try
{
await _pushService.PushChat(spm, sendingTo.UserId, sendingTo);
}
catch (Exception ex)
{
_logger.LogError(ex, "External push call failed for user {UserId} in department {DepartmentId}", sendingTo.UserId, departmentId);
return false;
}Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| } | ||
| else | ||
| { | ||
|
|
||
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.
NullReferenceException risk in Core/Resgrid.Services/CommunicationService.cs: the single-recipient chat path dereferences sendingTo.UserId before the null check, and a missing profile from GetProfileByUserIdAsync can produce recipients.FirstOrDefault() == null from a one-item [null] recipients list. Move the sendingTo null guard before assigning spm.Id and before calling CanSendToUser so SendChat can return false instead of throwing.
Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.