public async Task LeaveChannelAsync(ChannelRequest request) { var member = await _memberService.GetMemberBySaasUserIdAsync(request.SaasUserId); await _channelService.LeaveFromChannelAsync(request.SaasUserId, request.ChannelId); await _pushNotificationService.UnsubscribeUserFromTagAsync(member.SaasUserId, PushNotificationsTagTemplates.GetChatChannelTag(request.ChannelId.ToString())); await _channelNotificationService.OnLeaveChannel(member, request.ChannelId); await SendSystemMessageAsync(request.SaasUserId, request.ChannelId, new MemberLeftLocalizationVisitor(member), _systemMessagesConfiguration.MemberLeft, member.UserName); }
public async Task JoinToChannelAsync(ChannelRequest request) { // Locate the room, does NOT have to be open await _channelService.JoinToChannelAsync(request.SaasUserId, request.ChannelId); var channel = await _channelService.GetChannelSummaryAsync(request.SaasUserId, request.ChannelId); var member = await _memberService.GetMemberBySaasUserIdAsync(request.SaasUserId); await _pushNotificationService.SubscribeUserOnTagAsync(member.SaasUserId, PushNotificationsTagTemplates.GetChatChannelTag(request.ChannelId.ToString())); await _channelNotificationService.OnJoinChannel(member, channel); await SendSystemMessageAsync(request.SaasUserId, request.ChannelId, new MemberJoinedLocalizationVisitor(member), _systemMessagesConfiguration.MemberJoined, member.UserName); }
public async Task CloseChannelAsync(ChannelRequest request) { await _channelService.CloseChannelAsync(request.SaasUserId, request.ChannelId); var channelSummary = await _channelService.GetChannelSummaryAsync(request.SaasUserId, request.ChannelId); await _channelNotificationService.OnCloseChannel(channelSummary); var channelMembers = await _memberService.GetChannelMembersAsync(request.ChannelId); foreach (var member in channelMembers) { // unsubscribe user from channel await _pushNotificationService.UnsubscribeUserFromTagAsync(member.SaasUserId, PushNotificationsTagTemplates.GetChatChannelTag(request.ChannelId.ToString())); } // TODO [az]: do we need this notification? await _channelNotificationService.OnUpdateChannel(channelSummary); }