Exemple #1
0
        public static CommentDetailsView ToCommentDetailsView(this CommentRecordViewModel comment)
        {
            var commentDetailView = new CommentDetailsView()
            {
                Content              = comment.Content,
                Created              = comment.Created,
                CreatedByAdmin       = comment.CreatedByAdmin,
                Creator              = comment.Creator,
                FileMimeType         = comment.FileMimeType,
                FileURL              = comment.FileURL,
                Id                   = comment.Id.ToString(),
                Parent               = comment.Parent.GetValueOrDefault().ToString(),
                Root                 = comment.Root.GetValueOrDefault().ToString(),
                UpvoteCount          = comment.UpvoteCount,
                UserHasUpvoted       = comment.UserHasUpvoted,
                UserVoted            = comment.UserVoted,
                CreatedByCurrentUser = comment.CreatedByCurrentUser,
                IsNew                = comment.IsNew,
                Modified             = comment.Modified,
                GroupId              = comment.GroupId,
                CommentGroupType     = comment.CommentGroupType,
                Pings                = comment.Pings,// .PingsSequence,
                CreatorName          = comment.CreatorName,
                FileName             = comment.FileURL,
                Fullname             = comment.Fullname,
                GroupName            = comment.GroupName,
                PostOnURL            = comment.PostOnURL,//.CommentURL,
                ProfilePictureUrl    = comment.Creator
            };

            return(commentDetailView);
        }
Exemple #2
0
        public async Task PushCommentToGroupMembers(string messageRoomContentItemId, CommentDetailsView notificationComment)
        {
            //0. GetOnline Users ( array of (OnlineUser -with UserId, PartyId propererties))
            //1 .get message group participants
            //2 use join to filter from onlineusers list the message group participants
            //  https://stackoverflow.com/questions/3944803/use-linq-to-get-items-in-one-list-that-are-not-in-another-list
            //   https://stackoverflow.com/questions/37389027/use-linq-to-get-items-in-one-list-that-are-in-another-list  (BEST TO USE JOI FOR PERFORMACE EXPLAINED HERE)
            //3 for this subset of users push comment object to UI.

            // for each user in subset
            //4 await _hubContext.Clients.User(conn.UserId).SendAsync("RefreshChatNotificationNum", conn.Num, notificationComment);


            // var connectedUserNotificationNum = new List<ConnectedUserNotificationNum>();

            //0. GetOnline Users
            var connectedUserNotificationNumList = NotificationHub.Connections;

            //1.

            /*
             * //maybe could use field indexes to get group members
             * var groupMembersQuery = _session.QueryIndex<ContentPickerFieldIndex>(x =>x.SelectedContentItemId == comment.ContentItemId);
             * var groupMemberIdResults = (await groupMembersQuery.ListAsync()).Select(x=> x.ContentItemId);
             */
            // Lazy resolution to prevent cyclic dependency of content handlers
            var contentManamger = _serviceProvider.GetRequiredService <IContentManager>();
            var messageRoom     = await contentManamger.GetAsync(messageRoomContentItemId);

            var groupMemberPartyIds = new List <string>();

            if (messageRoom != null)
            {
                JArray jarrayitems = messageRoom.Content?.SelectToken("MessageRoom.Members.ContentItemIds");
                if (jarrayitems != null)
                {
                    groupMemberPartyIds = jarrayitems.ToObject <List <string> >();
                }
            }

            //2. create join with 2 datasets
            var joinedList = from p1 in connectedUserNotificationNumList
                             join p2 in groupMemberPartyIds
                             on p1.PartyContentItemId equals p2
                             select p1;

            // List<Person> joinedList = inboth.ToList();



            //.4
            foreach (var conn in joinedList)
            {
                if (conn.UserId != null)
                {
                    await _hubContext.Clients.User(conn.UserId).SendAsync("PushCommentToGroupMembers", notificationComment);
                }
            }
        }
Exemple #3
0
 private async Task PushChatNotificationNum(List <ConnectedUserNotificationNum> connectedUserNotificationNum, CommentDetailsView notificationComment)
 {
     foreach (var conn in connectedUserNotificationNum)
     {
         if (conn.UserId != null)
         {
             await _hubContext.Clients.User(conn.UserId).SendAsync("RefreshChatNotificationNum", conn.Num, notificationComment);
         }
     }
 }
Exemple #4
0
 public async Task PushNotifications(List <ConnectedUserNotificationNum> ConnectedUserNotificationNumList, CommentDetailsView notificationComment)
 {
     //Group chat case
     if (notificationComment.CommentGroupType == CommentGroupType.GroupChat)
     {
         await PushChatNotificationNum(ConnectedUserNotificationNumList, notificationComment);
     }
     //Profile chat case
     else if (notificationComment.CommentGroupType == CommentGroupType.ProfileChat)
     {
         await PushChatNotificationNum(ConnectedUserNotificationNumList, notificationComment);
     }
     //post on profile case
     else if (notificationComment.CommentGroupType == CommentGroupType.Group && notificationComment.Root == null)
     {
         await PushUserGeneralNotificationNum(ConnectedUserNotificationNumList, notificationComment);
     }
     //profile page case: send notification for all profile follower
     else if (notificationComment.CommentGroupType == CommentGroupType.Profile && notificationComment.Root == null)
     {
         await PushUserGeneralNotificationNum(ConnectedUserNotificationNumList, notificationComment);
     }
     //reply on notificationComment case: send notification for all user who was notificationComment on the post
     else if (notificationComment.Root != null)
     {
         await PushUserGeneralNotificationNum(ConnectedUserNotificationNumList, notificationComment);
     }
 }