feat: add no op push manager for de-googled

This commit is contained in:
0x330a 2023-04-20 17:25:03 +10:00
parent 8d4f2445f2
commit 7762d534bb
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
4 changed files with 39 additions and 3 deletions

View File

@ -1,5 +1,7 @@
package org.thoughtcrime.securesms.linkpreview;
import static org.session.libsession.utilities.Util.readFully;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -8,8 +10,6 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.gms.common.util.IOUtils;
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentTransferProgress;
import org.session.libsession.messaging.sending_receiving.attachments.UriAttachment;
@ -148,7 +148,7 @@ public class LinkPreviewRepository {
InputStream bodyStream = response.body().byteStream();
controller.setStream(bodyStream);
byte[] data = IOUtils.readInputStreamFully(bodyStream);
byte[] data = readFully(bodyStream);
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
Optional<Attachment> thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.JPEG, MediaTypes.IMAGE_JPEG);

View File

@ -28,6 +28,13 @@ class PushNotificationService : FirebaseMessagingService() {
override fun onMessageReceived(message: RemoteMessage) {
Log.d("Loki", "Received a push notification.")
if (message.data.containsKey("spns")) {
// assume this is the new push notification content
// deal with the enc payload (probably decrypting through the PushManager?
Log.d("Loki", "TODO: deal with the enc_payload\n${message.data["enc_payload"]}")
pushManager.decrypt(message.data)
return
}
val base64EncodedData = message.data?.get("ENCRYPTED_DATA")
val data = base64EncodedData?.let { Base64.decode(it) }
if (data != null) {

View File

@ -0,0 +1,14 @@
package org.thoughtcrime.securesms.notifications
import org.session.libsignal.utilities.Log
class NoOpPushManager: PushManager {
override fun register(force: Boolean) {
Log.d("NoOpPushManager", "Push notifications not supported, not registering for push notifications")
}
override fun unregister(token: String) {
Log.d("NoOpPushManager", "Push notifications not supported, not unregistering for push notifications")
}
}

View File

@ -0,0 +1,15 @@
package org.thoughtcrime.securesms.notifications
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
class NoOpPushModule {
@Provides
@Singleton
fun provideNoOpManager(): PushManager = NoOpPushManager()
}