Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Only certain notifications

laurenspriem0ba834955172
diff --git a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
index 0a1904fcb6..9ab7774c33 100644
--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
@@ -1119,21 +1119,6 @@ class RemoteSyncService {
final db = SocialDB.instance;
- final List<Reaction> photoLikes = await db.getReactionsOnFilesSince(
- excludeUserID: userID,
- sinceTime: cutoffTime,
- );
- for (final reaction in photoLikes) {
- considerCandidate(
- _SocialActivityCandidate(
- type: FeedItemType.photoLike,
- collectionID: reaction.collectionID,
- fileID: reaction.fileID,
- createdAt: reaction.createdAt,
- ),
- );
- }
-
final List<Comment> fileComments = await db.getCommentsOnFilesSince(
excludeUserID: userID,
sinceTime: cutoffTime,
@@ -1155,48 +1140,75 @@ class RemoteSyncService {
targetUserID: userID,
sinceTime: cutoffTime,
);
+ final List<Reaction> photoLikes = await db.getReactionsOnFilesSince(
+ excludeUserID: userID,
+ sinceTime: cutoffTime,
+ );
+
+ final repliesNeedingOwnerCheck = <Comment>[];
+ final fileIDsNeedingOwnership = <int>{};
+
for (final reply in replies) {
- considerCandidate(
- _SocialActivityCandidate(
- type: FeedItemType.reply,
- collectionID: reply.collectionID,
- fileID: reply.fileID,
- commentID: reply.id,
- commentText: reply.data,
- createdAt: reply.createdAt,
- ),
- );
+ if (reply.parentCommentUserID == userID) {
+ considerCandidate(
+ _SocialActivityCandidate(
+ type: FeedItemType.reply,
+ collectionID: reply.collectionID,
+ fileID: reply.fileID,
+ commentID: reply.id,
+ commentText: reply.data,
+ createdAt: reply.createdAt,
+ ),
+ );
+ } else if (reply.fileID != null) {
+ repliesNeedingOwnerCheck.add(reply);
+ fileIDsNeedingOwnership.add(reply.fileID!);
+ }
}
- final List<Reaction> commentLikes =
- await db.getReactionsOnUserCommentsSince(
- targetUserID: userID,
- sinceTime: cutoffTime,
- );
- for (final reaction in commentLikes) {
+ for (final reaction in photoLikes) {
+ if (reaction.fileID != null) {
+ fileIDsNeedingOwnership.add(reaction.fileID!);
+ }
+ }
+
+ final filesByID =
+ await _db.getFileIDToFileFromIDs(fileIDsNeedingOwnership.toList());
+
+ bool isOwnedByUser(int? fileID) {
+ if (fileID == null) {
+ return false;
+ }
+ final file = filesByID[fileID];
+ return file != null && file.ownerID == userID;
+ }
+
+ for (final reaction in photoLikes) {
+ if (!isOwnedByUser(reaction.fileID)) {
+ continue;
+ }
considerCandidate(
_SocialActivityCandidate(
- type: FeedItemType.commentLike,
+ type: FeedItemType.photoLike,
collectionID: reaction.collectionID,
fileID: reaction.fileID,
- commentID: reaction.commentID,
createdAt: reaction.createdAt,
),
);
}
- final List<Reaction> replyLikes = await db.getReactionsOnUserRepliesSince(
- targetUserID: userID,
- sinceTime: cutoffTime,
- );
- for (final reaction in replyLikes) {
+ for (final reply in repliesNeedingOwnerCheck) {
+ if (!isOwnedByUser(reply.fileID)) {
+ continue;
+ }
considerCandidate(
_SocialActivityCandidate(
- type: FeedItemType.replyLike,
- collectionID: reaction.collectionID,
- fileID: reaction.fileID,
- commentID: reaction.commentID,
- createdAt: reaction.createdAt,
+ type: FeedItemType.reply,
+ collectionID: reply.collectionID,
+ fileID: reply.fileID,
+ commentID: reply.id,
+ commentText: reply.data,
+ createdAt: reply.createdAt,
),
);
}