Skip to content

Commit b21740a

Browse files
authored
Merge pull request #1767 from DimensionDev/bugfix/bsky_notification
fix bsky build
2 parents 3db170d + 0e5c55d commit b21740a

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

shared/src/commonMain/kotlin/dev/dimension/flare/data/database/cache/mapper/Bluesky.kt

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import dev.dimension.flare.data.database.cache.model.StatusContent.BlueskyNotifi
3232
import dev.dimension.flare.data.database.cache.model.StatusContent.BlueskyNotification.UserList
3333
import dev.dimension.flare.data.database.cache.model.UserContent
3434
import dev.dimension.flare.model.AccountType
35+
import dev.dimension.flare.model.AccountType.Specific
3536
import dev.dimension.flare.model.MicroBlogKey
3637
import dev.dimension.flare.model.PlatformType
3738
import dev.dimension.flare.model.ReferenceType
@@ -243,7 +244,7 @@ internal fun List<ListNotificationsNotification>.toDb(
243244
id = items.joinToString("_") { it.uri.atUri } + idSuffix,
244245
host = accountKey.host,
245246
),
246-
accountType = AccountType.Specific(accountKey),
247+
accountType = Specific(accountKey),
247248
userKey = null,
248249
content = content,
249250
text = null,
@@ -287,7 +288,7 @@ internal fun List<ListNotificationsNotification>.toDb(
287288
id = items.joinToString("_") { it.uri.atUri } + "_follow",
288289
host = accountKey.host,
289290
),
290-
accountType = AccountType.Specific(accountKey),
291+
accountType = Specific(accountKey),
291292
userKey = null,
292293
content = content,
293294
text = null,
@@ -327,7 +328,7 @@ internal fun List<ListNotificationsNotification>.toDb(
327328
id = it.uri.atUri,
328329
host = accountKey.host,
329330
),
330-
accountType = AccountType.Specific(accountKey),
331+
accountType = Specific(accountKey),
331332
userKey = user.userKey,
332333
content = content,
333334
text = null,
@@ -367,7 +368,7 @@ internal fun List<ListNotificationsNotification>.toDb(
367368
id = it.uri.atUri,
368369
host = accountKey.host,
369370
),
370-
accountType = AccountType.Specific(accountKey),
371+
accountType = Specific(accountKey),
371372
userKey = user.userKey,
372373
content = content,
373374
text = null,
@@ -406,7 +407,7 @@ internal fun List<ListNotificationsNotification>.toDb(
406407
id = it.uri.atUri,
407408
host = accountKey.host,
408409
),
409-
accountType = AccountType.Specific(accountKey),
410+
accountType = Specific(accountKey),
410411
userKey = user.userKey,
411412
content = content,
412413
text = null,
@@ -445,7 +446,47 @@ internal fun List<ListNotificationsNotification>.toDb(
445446
id = it.uri.atUri,
446447
host = accountKey.host,
447448
),
448-
accountType = AccountType.Specific(accountKey),
449+
accountType = Specific(accountKey),
450+
userKey = user.userKey,
451+
content = content,
452+
text = null,
453+
createdAt = it.indexedAt,
454+
),
455+
)
456+
createDbPagingTimelineWithStatus(
457+
accountKey = accountKey,
458+
pagingKey = pagingKey,
459+
sortId = it.indexedAt.toEpochMilliseconds(),
460+
status = data,
461+
references =
462+
mapOf(
463+
ReferenceType.Notification to
464+
listOfNotNull(
465+
post.toDbStatusWithUser(
466+
accountKey,
467+
),
468+
),
469+
),
470+
)
471+
}
472+
}
473+
474+
ListNotificationsNotificationReason.ContactMatch -> {
475+
items.mapNotNull {
476+
val post = references[it.uri] ?: return@mapNotNull null
477+
val content = Post(post = post)
478+
val user = post.author.toDbUser(accountKey.host)
479+
val data =
480+
DbStatusWithUser(
481+
user = user,
482+
data =
483+
DbStatus(
484+
statusKey =
485+
MicroBlogKey(
486+
id = it.uri.atUri,
487+
host = accountKey.host,
488+
),
489+
accountType = Specific(accountKey),
449490
userKey = user.userKey,
450491
content = content,
451492
text = null,

shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/NotificationRemoteMediator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ internal class NotificationRemoteMediator(
9999
ListNotificationsNotificationReason.LikeViaRepost -> it.uri
100100
ListNotificationsNotificationReason.RepostViaRepost -> it.uri
101101
ListNotificationsNotificationReason.SubscribedPost -> it.uri
102+
ListNotificationsNotificationReason.ContactMatch -> it.uri
102103
}
103104
}.distinct()
104105
.toImmutableList()

shared/src/commonMain/kotlin/dev/dimension/flare/ui/model/mapper/Bluesky.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ private val ListNotificationsNotificationReason.icon: UiTimeline.TopMessage.Icon
459459
ListNotificationsNotificationReason.LikeViaRepost -> UiTimeline.TopMessage.Icon.Favourite
460460
ListNotificationsNotificationReason.RepostViaRepost -> UiTimeline.TopMessage.Icon.Retweet
461461
ListNotificationsNotificationReason.SubscribedPost -> UiTimeline.TopMessage.Icon.Info
462+
ListNotificationsNotificationReason.ContactMatch -> UiTimeline.TopMessage.Icon.Info
462463
}
463464

464465
private val ListNotificationsNotificationReason.type: UiTimeline.TopMessage.MessageType
@@ -477,6 +478,7 @@ private val ListNotificationsNotificationReason.type: UiTimeline.TopMessage.Mess
477478
ListNotificationsNotificationReason.LikeViaRepost -> UiTimeline.TopMessage.MessageType.Bluesky.Like
478479
ListNotificationsNotificationReason.RepostViaRepost -> UiTimeline.TopMessage.MessageType.Bluesky.Repost
479480
ListNotificationsNotificationReason.SubscribedPost -> UiTimeline.TopMessage.MessageType.Bluesky.UnKnown
481+
ListNotificationsNotificationReason.ContactMatch -> UiTimeline.TopMessage.MessageType.Bluesky.UnKnown
480482
}
481483

482484
internal fun PostView.render(

0 commit comments

Comments
 (0)