/// <summary> /// メッセージからメンションを検索し、含まれる場合はメンションを送信します。 /// </summary> /// <param name="message">メッセージ</param> /// <param name="roomId">メッセージが投稿されたルーム</param> /// <returns></returns> public async Task SendMention(string message, Guid roomId) { var mentions = MessageAnalyzer.GetMentionedUser(message); if (mentions.Contains("here")) { var usersBelongedToRoom = await _roomService.ReadUsersBelongedToRoom(roomId); await Task.WhenAll(usersBelongedToRoom.Select(async user => await _hubContext.Clients.User(user.ApplicationUser.Email) .SendAsync(SignalRMehod.SendMention, message))); return; } await Task.WhenAll(mentions.Select(async mention => { var userData = await _userService.ReadUser(mention, roomId); if (userData is not null) { await _hubContext.Clients.User(userData.ApplicationUser.Email) .SendAsync(SignalRMehod.SendMention, message); } })); }