public async Task <IActionResult> GetMessageAsync(int messageId) { if (!await messagesRepository.IsMessageUserAsync(messageId, int.Parse(User.Identity.Name))) { return(BadRequest()); } return(Ok(await messagesRepository.GetMessageAsync(messageId))); }
public async Task SendMessageReplyAsync(MMessageReply reply, string baseUrl) { var msg = await messagesRepository.GetMessageAsync(reply.MessageId); var sender = msg.FromUserId == reply.UserId ? msg.FromUser : msg.ToUser; var discordWebhookUrl = await usersRepository.GetUserDiscordWebhookUrl(msg.FromUserId == reply.UserId?msg.ToUserId : msg.FromUserId); if (string.IsNullOrEmpty(discordWebhookUrl)) { return; } var eb = new EmbedBuilder(); eb.WithColor(Color.Blue); eb.WithUrl(baseUrl + "/messages/" + msg.Id); eb.WithTitle($"New Reply Message #{msg.Id}"); eb.WithDescription($"{sender.Name} sent a new reply to message: **{msg.Title}**"); eb.WithFooter(sender.Name); eb.WithCurrentTimestamp(); SendEmbed(discordWebhookUrl, eb.Build()); }