mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
handle silent delete/delete-all push notifications
do not ignore talk messages (will only be sent if no talk app is installed) exclude generated Parcelable Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
9b0a789d3b
commit
51ee4d88fd
3 changed files with 23 additions and 14 deletions
|
@ -1,27 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
|
||||
<FindBugsFilter>
|
||||
<Match>
|
||||
<Class name="~.*\.Manifest\$.*"/>
|
||||
<Class name="~.*\.Manifest\$.*" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="~.*\.R\$.*"/>
|
||||
<Class name="~.*\.R\$.*" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="~.*\.R\$.*"/>
|
||||
<Class name="~.*\.R\$.*" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="~.*\$\$Parcelable.*" />
|
||||
</Match>
|
||||
|
||||
<!-- Dagger code is autogenerated. Exclude it from Check. -->
|
||||
<Match>
|
||||
<Or>
|
||||
<Class name="~.*\.Dagger.*"/>
|
||||
<Class name="~com.nextcloud.client.di\..*_.*"/>
|
||||
<Class name="~.*\.Dagger.*" />
|
||||
<Class name="~com.nextcloud.client.di\..*_.*" />
|
||||
</Or>
|
||||
</Match>
|
||||
<!-- Dagger generated code uses internal APIs -->
|
||||
<Match>
|
||||
<Class name="~.*\..*.*Factory"/>
|
||||
<Class name="~.*\..*.*Factory" />
|
||||
<Bug pattern="IICU_INCORRECT_INTERNAL_CLASS_USE" />
|
||||
</Match>
|
||||
|
||||
|
@ -30,5 +31,5 @@
|
|||
<Bug pattern="BAS_BLOATED_ASSIGNMENT_SCOPE" />
|
||||
|
||||
<!-- This is unmanageable for now due to large amount of interconnected static state -->
|
||||
<Bug pattern="FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY"/>
|
||||
<Bug pattern="FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY" />
|
||||
</FindBugsFilter>
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -41,4 +43,7 @@ public class DecryptedPushMessage {
|
|||
public String subject;
|
||||
public String id;
|
||||
public int nid;
|
||||
public boolean delete;
|
||||
@SerializedName("delete-all")
|
||||
public boolean deleteAll;
|
||||
}
|
||||
|
|
|
@ -95,9 +95,7 @@ public class NotificationJob extends Job {
|
|||
private static final String KEY_NOTIFICATION_ACTION_TYPE = "KEY_NOTIFICATION_ACTION_TYPE";
|
||||
private static final String PUSH_NOTIFICATION_ID = "PUSH_NOTIFICATION_ID";
|
||||
private static final String NUMERIC_NOTIFICATION_ID = "NUMERIC_NOTIFICATION_ID";
|
||||
private static final String APP_SPREED = "spreed";
|
||||
|
||||
private SecureRandom randomId = new SecureRandom();
|
||||
private Context context;
|
||||
private UserAccountManager accountManager;
|
||||
|
||||
|
@ -110,6 +108,7 @@ public class NotificationJob extends Job {
|
|||
@Override
|
||||
protected Result onRunJob(@NonNull Params params) {
|
||||
context = getContext();
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
PersistableBundleCompat persistableBundleCompat = getParams().getExtras();
|
||||
String subject = persistableBundleCompat.getString(KEY_NOTIFICATION_SUBJECT, "");
|
||||
String signature = persistableBundleCompat.getString(KEY_NOTIFICATION_SIGNATURE, "");
|
||||
|
@ -135,8 +134,11 @@ public class NotificationJob extends Job {
|
|||
DecryptedPushMessage decryptedPushMessage = gson.fromJson(new String(decryptedSubject),
|
||||
DecryptedPushMessage.class);
|
||||
|
||||
// We ignore Spreed messages for now
|
||||
if (!APP_SPREED.equals(decryptedPushMessage.getApp())) {
|
||||
if (decryptedPushMessage.delete) {
|
||||
notificationManager.cancel(decryptedPushMessage.nid);
|
||||
} else if (decryptedPushMessage.deleteAll) {
|
||||
notificationManager.cancelAll();
|
||||
} else {
|
||||
fetchCompleteNotification(signatureVerification.getAccount(), decryptedPushMessage);
|
||||
}
|
||||
}
|
||||
|
@ -152,6 +154,7 @@ public class NotificationJob extends Job {
|
|||
}
|
||||
|
||||
private void sendNotification(Notification notification, Account account) {
|
||||
SecureRandom randomId = new SecureRandom();
|
||||
RichObject file = notification.subjectRichParameters.get("file");
|
||||
|
||||
Intent intent;
|
||||
|
@ -234,7 +237,7 @@ public class NotificationJob extends Job {
|
|||
.setContentIntent(pendingIntent).build());
|
||||
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
notificationManager.notify(pushNotificationId, notificationBuilder.build());
|
||||
notificationManager.notify(notification.getNotificationId(), notificationBuilder.build());
|
||||
}
|
||||
|
||||
private void fetchCompleteNotification(Account account, DecryptedPushMessage decryptedPushMessage) {
|
||||
|
|
Loading…
Reference in a new issue