Add notifications to user when a follow profile posted

This commit is contained in:
Adolfo Reyna
2024-12-31 16:28:31 -05:00
parent 433f3069b3
commit d79138fba6
3 changed files with 30 additions and 2 deletions

View File

@@ -445,6 +445,21 @@ const Notifications = {
return this.yourGroupGotANewPost(profile, profile, message, post);
}
},
async yourSubscriptionProfileHasNewPost(post) {
const whoPostedId = post.profileid;
const message = post.content;
const DB = await DBGetter.getDB;
const profile = await DB.getProfileCache(whoPostedId);
const subscribed_profiles = await DB.getFollowingTheProfile(whoPostedId);
subscribed_profiles.forEach((subscribed_id, index) => {
const userProfile = subscribed_profiles[index];
if (userProfile._id == whoPostedId._id) return 0;
const notifBody = `${profile.profile.firstName} posted: ${message.substring(0, 50)}...`;
sendPushNotification(userProfile.token, notifBody, {});
//sendWebNotification(userProfile.webSubscription, notifBody, message);
DB.addNotification(userProfile._id, notifBody, post._id, null, profile._id);
});
},
youHaveAnInvitation,
broadcastNews,
async yourGroupHasARequest(requesterProfileId, groupId) {