public async void CreateGroupChat(CreateGroupChatRequest request) { var dbWorker = DIFactory.Resolve <IDbSystemWorker>(); await dbWorker.CreateGroupChat(request.ChatName, request.CreatorGuid, request.UserGuids); foreach (var user in _users) { try { NeedUpdateChats(user.UserGuid); } catch (Exception e) { _logger.Write(LogLevel.Error, "Error callback message", e); } } }
public CreateGroupChatResponse CreateGroupChat(ISession session, CreateGroupChatRequest request) { var response = request.CreateResponse <CreateGroupChatResponse>(); GroupChat group = new GroupChat { GroupId = Guid.NewGuid(), CreatedAt = DateTime.UtcNow, OwnerId = session.UserId }; group.Participants = new List <GroupChatParticipant> { new GroupChatParticipant { UserId = session.UserId } }; group.Participants.AddRange(request.Participants.Select(i => new GroupChatParticipant { UserId = i })); foreach (var participant in group.Participants) { _groupChatsRepository.AddGroupToUser(participant.UserId, group.GroupId); participant.Devices = _devicesRepository.GetDevices(participant.UserId); } foreach (var device in group.Participants.SelectMany(p => p.Devices)) { if (device != session.DeviceId) { _groupChangedEventManager.DeliverEventToDevice(new GroupChangedEvent { ReceiverDeviceId = device, ChangesAuthorId = session.UserId, GroupId = group.GroupId, Participants = group.Participants, Type = GroupChangedEvent.ChangesType.ParticipantsAdded }); } } _groupChatsRepository.UpdateOrCreateGroup(group); response.GroupId = group.GroupId; return(response); }
public void CreateGroupChat(CreateGroupChatRequest request) { _channel.CreateGroupChat(request); }
public Task <CreateGroupChatResponse> CreateGroupChat(CreateGroupChatRequest request) { return(_connectionManager.SendRequestAndWaitResponse <CreateGroupChatResponse>(request)); }