- Adds created_at as the time of the notification instead of the receiving time
- Displays Zap Push notifications even if the zapped note is not available yet.
This commit is contained in:
+49
-15
@@ -161,6 +161,7 @@ class EventNotificationConsumer(
|
|||||||
event.id,
|
event.id,
|
||||||
content,
|
content,
|
||||||
user,
|
user,
|
||||||
|
event.createdAt,
|
||||||
userPicture,
|
userPicture,
|
||||||
noteUri,
|
noteUri,
|
||||||
applicationContext,
|
applicationContext,
|
||||||
@@ -201,7 +202,7 @@ class EventNotificationConsumer(
|
|||||||
val userPicture = note.author?.profilePicture()
|
val userPicture = note.author?.profilePicture()
|
||||||
val noteUri = note.toNEvent()
|
val noteUri = note.toNEvent()
|
||||||
notificationManager()
|
notificationManager()
|
||||||
.sendDMNotification(event.id, content, user, userPicture, noteUri, applicationContext)
|
.sendDMNotification(event.id, content, user, event.createdAt, userPicture, noteUri, applicationContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,31 +245,63 @@ class EventNotificationConsumer(
|
|||||||
val author = LocalCache.getOrCreateUser(it.pubKey)
|
val author = LocalCache.getOrCreateUser(it.pubKey)
|
||||||
val senderInfo = Pair(author, it.content.ifBlank { null })
|
val senderInfo = Pair(author, it.content.ifBlank { null })
|
||||||
|
|
||||||
acc.decryptContent(noteZapped) {
|
if (noteZapped.event?.content() != null) {
|
||||||
Log.d("EventNotificationConsumer", "Notify Decrypted if Private Note")
|
acc.decryptContent(noteZapped) {
|
||||||
|
Log.d("EventNotificationConsumer", "Notify Decrypted if Private Note")
|
||||||
|
|
||||||
val zappedContent = it.split("\n").get(0)
|
val zappedContent = it.split("\n").get(0)
|
||||||
|
|
||||||
|
val user = senderInfo.first.toBestDisplayName()
|
||||||
|
var title = stringRes(applicationContext, R.string.app_notification_zaps_channel_message, amount)
|
||||||
|
senderInfo.second?.ifBlank { null }?.let { title += " ($it)" }
|
||||||
|
|
||||||
|
var content =
|
||||||
|
stringRes(
|
||||||
|
applicationContext,
|
||||||
|
R.string.app_notification_zaps_channel_message_from,
|
||||||
|
user,
|
||||||
|
)
|
||||||
|
zappedContent.let {
|
||||||
|
content +=
|
||||||
|
" " +
|
||||||
|
stringRes(
|
||||||
|
applicationContext,
|
||||||
|
R.string.app_notification_zaps_channel_message_for,
|
||||||
|
zappedContent,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val userPicture = senderInfo?.first?.profilePicture()
|
||||||
|
val noteUri = "nostr:Notifications"
|
||||||
|
|
||||||
|
Log.d("EventNotificationConsumer", "Notify ${event.id} $content $title $noteUri")
|
||||||
|
|
||||||
|
notificationManager()
|
||||||
|
.sendZapNotification(
|
||||||
|
event.id,
|
||||||
|
content,
|
||||||
|
title,
|
||||||
|
event.createdAt,
|
||||||
|
userPicture,
|
||||||
|
noteUri,
|
||||||
|
applicationContext,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// doesn't have a base note to refer to.
|
||||||
|
Log.d("EventNotificationConsumer", "Notify Zapped note not available")
|
||||||
|
|
||||||
val user = senderInfo.first.toBestDisplayName()
|
val user = senderInfo.first.toBestDisplayName()
|
||||||
var title = stringRes(applicationContext, R.string.app_notification_zaps_channel_message, amount)
|
var title = stringRes(applicationContext, R.string.app_notification_zaps_channel_message, amount)
|
||||||
senderInfo.second?.ifBlank { null }?.let { title += " ($it)" }
|
senderInfo.second?.ifBlank { null }?.let { title += " ($it)" }
|
||||||
|
|
||||||
var content =
|
val content =
|
||||||
stringRes(
|
stringRes(
|
||||||
applicationContext,
|
applicationContext,
|
||||||
R.string.app_notification_zaps_channel_message_from,
|
R.string.app_notification_zaps_channel_message_from,
|
||||||
user,
|
user,
|
||||||
)
|
)
|
||||||
zappedContent.let {
|
|
||||||
content +=
|
val userPicture = senderInfo.first.profilePicture()
|
||||||
" " +
|
|
||||||
stringRes(
|
|
||||||
applicationContext,
|
|
||||||
R.string.app_notification_zaps_channel_message_for,
|
|
||||||
zappedContent,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val userPicture = senderInfo?.first?.profilePicture()
|
|
||||||
val noteUri = "nostr:Notifications"
|
val noteUri = "nostr:Notifications"
|
||||||
|
|
||||||
Log.d("EventNotificationConsumer", "Notify ${event.id} $content $title $noteUri")
|
Log.d("EventNotificationConsumer", "Notify ${event.id} $content $title $noteUri")
|
||||||
@@ -278,6 +311,7 @@ class EventNotificationConsumer(
|
|||||||
event.id,
|
event.id,
|
||||||
content,
|
content,
|
||||||
title,
|
title,
|
||||||
|
event.createdAt,
|
||||||
userPicture,
|
userPicture,
|
||||||
noteUri,
|
noteUri,
|
||||||
applicationContext,
|
applicationContext,
|
||||||
|
|||||||
+10
@@ -90,6 +90,7 @@ object NotificationUtils {
|
|||||||
id: String,
|
id: String,
|
||||||
messageBody: String,
|
messageBody: String,
|
||||||
messageTitle: String,
|
messageTitle: String,
|
||||||
|
time: Long,
|
||||||
pictureUrl: String?,
|
pictureUrl: String?,
|
||||||
uri: String,
|
uri: String,
|
||||||
applicationContext: Context,
|
applicationContext: Context,
|
||||||
@@ -101,6 +102,7 @@ object NotificationUtils {
|
|||||||
id,
|
id,
|
||||||
messageBody,
|
messageBody,
|
||||||
messageTitle,
|
messageTitle,
|
||||||
|
time,
|
||||||
pictureUrl,
|
pictureUrl,
|
||||||
uri,
|
uri,
|
||||||
channelId,
|
channelId,
|
||||||
@@ -113,6 +115,7 @@ object NotificationUtils {
|
|||||||
id: String,
|
id: String,
|
||||||
messageBody: String,
|
messageBody: String,
|
||||||
messageTitle: String,
|
messageTitle: String,
|
||||||
|
time: Long,
|
||||||
pictureUrl: String?,
|
pictureUrl: String?,
|
||||||
uri: String,
|
uri: String,
|
||||||
applicationContext: Context,
|
applicationContext: Context,
|
||||||
@@ -124,6 +127,7 @@ object NotificationUtils {
|
|||||||
id,
|
id,
|
||||||
messageBody,
|
messageBody,
|
||||||
messageTitle,
|
messageTitle,
|
||||||
|
time,
|
||||||
pictureUrl,
|
pictureUrl,
|
||||||
uri,
|
uri,
|
||||||
channelId,
|
channelId,
|
||||||
@@ -136,6 +140,7 @@ object NotificationUtils {
|
|||||||
id: String,
|
id: String,
|
||||||
messageBody: String,
|
messageBody: String,
|
||||||
messageTitle: String,
|
messageTitle: String,
|
||||||
|
time: Long,
|
||||||
pictureUrl: String?,
|
pictureUrl: String?,
|
||||||
uri: String,
|
uri: String,
|
||||||
channelId: String,
|
channelId: String,
|
||||||
@@ -151,6 +156,7 @@ object NotificationUtils {
|
|||||||
id = id,
|
id = id,
|
||||||
messageBody = messageBody,
|
messageBody = messageBody,
|
||||||
messageTitle = messageTitle,
|
messageTitle = messageTitle,
|
||||||
|
time = time,
|
||||||
picture = imageResult.drawable as? BitmapDrawable,
|
picture = imageResult.drawable as? BitmapDrawable,
|
||||||
uri = uri,
|
uri = uri,
|
||||||
channelId,
|
channelId,
|
||||||
@@ -162,6 +168,7 @@ object NotificationUtils {
|
|||||||
id = id,
|
id = id,
|
||||||
messageBody = messageBody,
|
messageBody = messageBody,
|
||||||
messageTitle = messageTitle,
|
messageTitle = messageTitle,
|
||||||
|
time = time,
|
||||||
picture = null,
|
picture = null,
|
||||||
uri = uri,
|
uri = uri,
|
||||||
channelId,
|
channelId,
|
||||||
@@ -175,6 +182,7 @@ object NotificationUtils {
|
|||||||
id: String,
|
id: String,
|
||||||
messageBody: String,
|
messageBody: String,
|
||||||
messageTitle: String,
|
messageTitle: String,
|
||||||
|
time: Long,
|
||||||
picture: BitmapDrawable?,
|
picture: BitmapDrawable?,
|
||||||
uri: String,
|
uri: String,
|
||||||
channelId: String,
|
channelId: String,
|
||||||
@@ -218,6 +226,7 @@ object NotificationUtils {
|
|||||||
.setContentIntent(contentPendingIntent)
|
.setContentIntent(contentPendingIntent)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
|
.setWhen(time * 1000)
|
||||||
|
|
||||||
// Build the notification
|
// Build the notification
|
||||||
val builder =
|
val builder =
|
||||||
@@ -236,6 +245,7 @@ object NotificationUtils {
|
|||||||
.setPublicVersion(builderPublic.build())
|
.setPublicVersion(builderPublic.build())
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
|
.setWhen(time * 1000)
|
||||||
|
|
||||||
notify(notId, builder.build())
|
notify(notId, builder.build())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user