Skip to content
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

Support delete-multiple push notification #1142

Merged
merged 5 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
)
} else if (deleteAll) {
cancelAllNotificationsForAccount(applicationContext, signatureVerification!!.userEntity)
} else if (deleteMultiple) {
notificationIds.forEach {
AndyScherzinger marked this conversation as resolved.
Show resolved Hide resolved
cancelExistingNotificationWithId(
applicationContext,
signatureVerification!!.userEntity,
it
)
}
} else if (type == "call") {
val fullScreenIntent = Intent(applicationContext, MagicCallActivity::class.java)
val bundle = Bundle()
Expand Down Expand Up @@ -201,7 +209,11 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
LoganSquare.parse(ringtonePreferencesString, RingtoneSettings::class.java)
ringtoneSettings.ringtoneUri
} catch (exception: IOException) {
Uri.parse("android.resource://" + applicationContext.packageName + "/raw/librem_by_feandesign_call")
Uri.parse(
"android.resource://" +
applicationContext.packageName +
"/raw/librem_by_feandesign_call"
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@ public Result doWork() {
NotificationUtils.INSTANCE.cancelExistingNotificationWithId(context, signatureVerification.getUserEntity(), decryptedPushMessage.getNotificationId());
} else if (decryptedPushMessage.isDeleteAll()) {
NotificationUtils.INSTANCE.cancelAllNotificationsForAccount(context, signatureVerification.getUserEntity());
} else if (decryptedPushMessage.isDeleteMultiple()) {
for (long notificationId : decryptedPushMessage.getNotificationIds()) {
NotificationUtils.INSTANCE.cancelExistingNotificationWithId(context, signatureVerification.getUserEntity(), notificationId);
}
} else {
credentials = ApiUtils.getCredentials(signatureVerification.getUserEntity().getUsername(),
signatureVerification.getUserEntity().getToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ public class DecryptedPushMessage {
@JsonField(name = "nid")
public long notificationId;

@JsonField(name = "nids")
public long[] notificationIds;

@JsonField(name = "delete")
public boolean delete;

@JsonField(name = "delete-all")
public boolean deleteAll;

@JsonField(name = "delete-multiple")
public boolean deleteMultiple;

@JsonIgnore
public NotificationUser notificationUser;

Expand Down Expand Up @@ -99,6 +105,14 @@ public long getTimestamp() {
return this.timestamp;
}

public long[] getNotificationIds() {
return notificationIds;
}

public boolean isDeleteMultiple() {
return deleteMultiple;
}

public void setApp(String app) {
this.app = app;
}
Expand Down Expand Up @@ -139,6 +153,14 @@ public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}

public void setNotificationIds(long[] notificationIds) {
this.notificationIds = notificationIds;
}

public void setDeleteMultiple(boolean deleteMultiple) {
this.deleteMultiple = deleteMultiple;
}

public boolean equals(final Object o) {
if (o == this) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion scripts/analysis/findbugs-results.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
499
489
4 changes: 4 additions & 0 deletions spotbugs-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<Match>
<Class name="~.*\$\$Parcelable.*" />
</Match>
<!-- JSON/Data classes with generated accessor methods -->
<Match>
<Class name="~com\.nextcloud\.talk\.models\.json\.push.*" />
</Match>

<!-- Dagger code is autogenerated. Exclude it from Check. -->
<Match>
Expand Down