mirror of
				https://codeberg.org/tom79/Fedilab.git
				synced 2025-10-20 11:20:16 +03:00 
			
		
		
		
	Fix reactions displayed in all notif tabs
This commit is contained in:
		
							parent
							
								
									7e1d9b8910
								
							
						
					
					
						commit
						c052e376e2
					
				
					 5 changed files with 6 additions and 20 deletions
				
			
		| 
						 | 
					@ -19,7 +19,6 @@ import static app.fedilab.android.client.entities.app.StatusCache.restoreNotific
 | 
				
			||||||
import android.content.Context;
 | 
					import android.content.Context;
 | 
				
			||||||
import android.content.SharedPreferences;
 | 
					import android.content.SharedPreferences;
 | 
				
			||||||
import android.util.Base64;
 | 
					import android.util.Base64;
 | 
				
			||||||
import android.util.Log;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import androidx.preference.PreferenceManager;
 | 
					import androidx.preference.PreferenceManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,23 +143,14 @@ public class ECDHFedilab {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        SharedPreferences sharedPreferences = PreferenceManager
 | 
					        SharedPreferences sharedPreferences = PreferenceManager
 | 
				
			||||||
                .getDefaultSharedPreferences(context);
 | 
					                .getDefaultSharedPreferences(context);
 | 
				
			||||||
        Log.v(Helper.TAG, ">>slug: " + slug);
 | 
					 | 
				
			||||||
        String pushPrivateKey = sharedPreferences.getString("pushPrivateKey" + slug, null);
 | 
					        String pushPrivateKey = sharedPreferences.getString("pushPrivateKey" + slug, null);
 | 
				
			||||||
        String pushPublicKey = sharedPreferences.getString("pushPublicKey" + slug, null);
 | 
					        String pushPublicKey = sharedPreferences.getString("pushPublicKey" + slug, null);
 | 
				
			||||||
        String encodedAuthKey = sharedPreferences.getString("encodedAuthKey" + slug, null);
 | 
					        String encodedAuthKey = sharedPreferences.getString("encodedAuthKey" + slug, null);
 | 
				
			||||||
        sharedPreferences.getString("pushAccountID" + slug, null);
 | 
					        sharedPreferences.getString("pushAccountID" + slug, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Log.v(Helper.TAG, "getServerKey(context, slug): " + getServerKey(context, slug));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Log.v(Helper.TAG, "pushPrivateKey: " + pushPrivateKey);
 | 
					 | 
				
			||||||
        Log.v(Helper.TAG, "pushPublicKey: " + pushPublicKey);
 | 
					 | 
				
			||||||
        Log.v(Helper.TAG, "encodedAuthKey: " + encodedAuthKey);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        PublicKey serverKey = null;
 | 
					        PublicKey serverKey = null;
 | 
				
			||||||
        serverKey = deserializeRawPublicKey(Base64.decode(getServerKey(context, slug), Base64.URL_SAFE));
 | 
					        serverKey = deserializeRawPublicKey(Base64.decode(getServerKey(context, slug), Base64.URL_SAFE));
 | 
				
			||||||
        Log.v(Helper.TAG, "serverKey: " + serverKey);
 | 
					 | 
				
			||||||
        PrivateKey privateKey;
 | 
					        PrivateKey privateKey;
 | 
				
			||||||
        PublicKey publicKey;
 | 
					        PublicKey publicKey;
 | 
				
			||||||
        byte[] authKey;
 | 
					        byte[] authKey;
 | 
				
			||||||
| 
						 | 
					@ -171,7 +161,6 @@ public class ECDHFedilab {
 | 
				
			||||||
            authKey = Base64.decode(encodedAuthKey, Base64.URL_SAFE);
 | 
					            authKey = Base64.decode(encodedAuthKey, Base64.URL_SAFE);
 | 
				
			||||||
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
 | 
					        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            Log.v(Helper.TAG, "err1: " + e.getMessage());
 | 
					 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        byte[] sharedSecret;
 | 
					        byte[] sharedSecret;
 | 
				
			||||||
| 
						 | 
					@ -182,7 +171,6 @@ public class ECDHFedilab {
 | 
				
			||||||
            sharedSecret = keyAgreement.generateSecret();
 | 
					            sharedSecret = keyAgreement.generateSecret();
 | 
				
			||||||
        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
 | 
					        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            Log.v(Helper.TAG, "err2: " + e.getMessage());
 | 
					 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        byte[] secondSaltInfo = "Content-Encoding: auth\0".getBytes(StandardCharsets.UTF_8);
 | 
					        byte[] secondSaltInfo = "Content-Encoding: auth\0".getBytes(StandardCharsets.UTF_8);
 | 
				
			||||||
| 
						 | 
					@ -191,7 +179,6 @@ public class ECDHFedilab {
 | 
				
			||||||
            deriveKey = deriveKey(authKey, sharedSecret, secondSaltInfo, 32);
 | 
					            deriveKey = deriveKey(authKey, sharedSecret, secondSaltInfo, 32);
 | 
				
			||||||
        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
 | 
					        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            Log.v(Helper.TAG, "err3: " + e.getMessage());
 | 
					 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        String decryptedStr;
 | 
					        String decryptedStr;
 | 
				
			||||||
| 
						 | 
					@ -207,7 +194,6 @@ public class ECDHFedilab {
 | 
				
			||||||
            decryptedStr = new String(decrypted, 2, decrypted.length - 2, StandardCharsets.UTF_8);
 | 
					            decryptedStr = new String(decrypted, 2, decrypted.length - 2, StandardCharsets.UTF_8);
 | 
				
			||||||
        } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException e) {
 | 
					        } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            Log.v(Helper.TAG, "err4: " + e.getMessage());
 | 
					 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return restoreNotificationFromString(decryptedStr);
 | 
					        return restoreNotificationFromString(decryptedStr);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,6 @@ import android.content.Context;
 | 
				
			||||||
import android.content.SharedPreferences;
 | 
					import android.content.SharedPreferences;
 | 
				
			||||||
import android.os.Handler;
 | 
					import android.os.Handler;
 | 
				
			||||||
import android.os.Looper;
 | 
					import android.os.Looper;
 | 
				
			||||||
import android.util.Log;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import androidx.annotation.NonNull;
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
import androidx.preference.PreferenceManager;
 | 
					import androidx.preference.PreferenceManager;
 | 
				
			||||||
| 
						 | 
					@ -104,7 +103,6 @@ public class PushNotifications {
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                } catch (Exception e) {
 | 
					                } catch (Exception e) {
 | 
				
			||||||
                    Log.v(Helper.TAG, slug + " -> " + e.getMessage());
 | 
					 | 
				
			||||||
                    e.printStackTrace();
 | 
					                    e.printStackTrace();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,6 @@ package app.fedilab.android.services;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import android.content.Context;
 | 
					import android.content.Context;
 | 
				
			||||||
import android.content.Intent;
 | 
					import android.content.Intent;
 | 
				
			||||||
import android.util.Log;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import androidx.annotation.NonNull;
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +23,6 @@ import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
import org.jetbrains.annotations.Nullable;
 | 
					import org.jetbrains.annotations.Nullable;
 | 
				
			||||||
import org.unifiedpush.android.connector.MessagingReceiver;
 | 
					import org.unifiedpush.android.connector.MessagingReceiver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import app.fedilab.android.helper.Helper;
 | 
					 | 
				
			||||||
import app.fedilab.android.helper.NotificationsHelper;
 | 
					import app.fedilab.android.helper.NotificationsHelper;
 | 
				
			||||||
import app.fedilab.android.helper.PushNotifications;
 | 
					import app.fedilab.android.helper.PushNotifications;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +38,6 @@ public class CustomReceiver extends MessagingReceiver {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onMessage(@NotNull Context context, @NotNull byte[] message, @NotNull String slug) {
 | 
					    public void onMessage(@NotNull Context context, @NotNull byte[] message, @NotNull String slug) {
 | 
				
			||||||
        // Called when a new message is received. The message contains the full POST body of the push message
 | 
					        // Called when a new message is received. The message contains the full POST body of the push message
 | 
				
			||||||
        Log.v(Helper.TAG, "onMessage: " + slug);
 | 
					 | 
				
			||||||
        new Thread(() -> {
 | 
					        new Thread(() -> {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                /*Notification notification = ECDHFedilab.decryptNotification(context, slug, message);
 | 
					                /*Notification notification = ECDHFedilab.decryptNotification(context, slug, message);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -186,7 +186,11 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
 | 
				
			||||||
                case "admin.report":
 | 
					                case "admin.report":
 | 
				
			||||||
                    return TYPE_ADMIN_REPORT;
 | 
					                    return TYPE_ADMIN_REPORT;
 | 
				
			||||||
                case "pleroma:emoji_reaction":
 | 
					                case "pleroma:emoji_reaction":
 | 
				
			||||||
 | 
					                    if (notificationList.get(position).status != null) {
 | 
				
			||||||
                        return TYPE_REACTION;
 | 
					                        return TYPE_REACTION;
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        return TYPE_HIDDEN;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return super.getItemViewType(position);
 | 
					        return super.getItemViewType(position);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -209,6 +209,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
 | 
				
			||||||
        excludeType.add("status");
 | 
					        excludeType.add("status");
 | 
				
			||||||
        excludeType.add("admin.sign_up");
 | 
					        excludeType.add("admin.sign_up");
 | 
				
			||||||
        excludeType.add("admin.report");
 | 
					        excludeType.add("admin.report");
 | 
				
			||||||
 | 
					        excludeType.add("pleroma:emoji_reaction");
 | 
				
			||||||
        if (notificationType == NotificationTypeEnum.ALL) {
 | 
					        if (notificationType == NotificationTypeEnum.ALL) {
 | 
				
			||||||
            aggregateNotification = sharedpreferences.getBoolean(getString(R.string.SET_AGGREGATE_NOTIFICATION), true);
 | 
					            aggregateNotification = sharedpreferences.getBoolean(getString(R.string.SET_AGGREGATE_NOTIFICATION), true);
 | 
				
			||||||
            if (excludedCategories != null) {
 | 
					            if (excludedCategories != null) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue