-
-
Notifications
You must be signed in to change notification settings - Fork 45
Notifications Parser refactor and tests #3455
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
6039427
c80f698
cb09195
a047d89
1996e7f
844e842
de419b2
3c0c345
b0f7303
ef9714b
c1b156b
78932ff
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 |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| package org.commcare.connect.network.connectId; | ||
|
|
||
| import static org.commcare.connect.network.NetworkUtils.getErrorCodes; | ||
|
|
||
| import android.app.Activity; | ||
| import android.content.Context; | ||
|
|
||
|
|
@@ -10,6 +12,7 @@ | |
| import org.commcare.connect.network.NoParsingResponseParser; | ||
| import org.commcare.connect.network.base.BaseApiCallback; | ||
| import org.commcare.connect.network.base.BaseApiHandler; | ||
| import org.commcare.connect.network.base.BaseApiResponseParser; | ||
| import org.commcare.connect.network.connectId.parser.AddOrVerifyNameParser; | ||
| import org.commcare.connect.network.connectId.parser.CompleteProfileResponseParser; | ||
| import org.commcare.connect.network.connectId.parser.ConfirmBackupCodeResponseParser; | ||
|
|
@@ -33,8 +36,6 @@ | |
|
|
||
| import kotlin.Pair; | ||
|
|
||
| import static org.commcare.connect.network.NetworkUtils.getErrorCodes; | ||
|
|
||
| public abstract class PersonalIdApiHandler<T> extends BaseApiHandler<T> { | ||
|
|
||
|
|
||
|
|
@@ -299,14 +300,12 @@ public void heartbeatRequest(Context context, ConnectUserRecord user) { | |
| ); | ||
| } | ||
|
|
||
|
|
||
| public void retrieveNotifications(Context context, ConnectUserRecord user) { | ||
| ApiPersonalId.retrieveNotifications( | ||
| context, | ||
| user.getUserId(), | ||
| user.getPassword(), | ||
| createCallback(new RetrieveNotificationsResponseParser<>(context), null) | ||
| ); | ||
| createCallback((BaseApiResponseParser<T>) new RetrieveNotificationsResponseParser(context), null)); | ||
|
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. @shubham1g5 Why data type casting is required here?
Contributor
Author
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. It's required due to the change in
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. We can still keep
Contributor
Author
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. No strong thoughts on my end, Do you have a sense of why one is better than other ?
Contributor
Author
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. Seems like we need to cast over here or as done in this PR. |
||
| } | ||
|
|
||
| public void updateNotifications( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package org.commcare.connect.network.connectId.parser | ||
|
|
||
| import org.commcare.android.database.connect.models.ConnectMessagingChannelRecord | ||
| import org.commcare.android.database.connect.models.ConnectMessagingMessageRecord | ||
| import org.commcare.android.database.connect.models.PushNotificationRecord | ||
|
|
||
| /** | ||
| * Data class to hold the result of parsing notification response | ||
| * Contains three separate, exclusive entities: notifications, channels, and messages | ||
| */ | ||
| data class NotificationParseResult( | ||
| val nonMessagingNotifications: List<PushNotificationRecord>, | ||
| val channels: List<ConnectMessagingChannelRecord>, | ||
| val messages: List<ConnectMessagingMessageRecord>, | ||
| val messagingNotificationIds: List<String>, | ||
| ) |
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.
Potential NPE if
DateUtils.parseDateTimereturns null.DateUtils.parseDateTime(dateString)can returnnullif the date string cannot be parsed. AssigningnulltocreatedDate(which is non-nullDate) will cause issues. Consider adding null-safety:📝 Committable suggestion
🤖 Prompt for AI Agents