public async Task <ActionResult> SendPrivateMessageAsync([FromBody] SendPrivateMessageRequest Request) { if (Request == null) { return(BadRequest()); } return(Json(await _privateMessageService.SendPrivateMessageAsync(Request))); }
public async Task <ActionResult> SendPrivateMessageAsync([FromBody] SendPrivateMessageRequest Request) { if (Request == null) { return(BadRequest()); } if (_apiPrincipal.IsAttendee) { Request.AuthorName = _apiPrincipal.GivenName; } return(Json(await _privateMessageService.SendPrivateMessageAsync(Request, _apiPrincipal.Uid))); }
private async Task SendItemsToAuctionNotificationAsync(string recipientUid, IList <ItemActivityRecord> items) { var title = $"{items.Count} item(s) will participate in the auction"; var message = new StringBuilder(); message.AppendLine( $"{items.Count} item(s) on which you have been the last bidder will be part of the auction.\n"); foreach (var item in items) { message.AppendLine($"{item.ASIDNO}: \"{item.ArtPieceTitle}\" by \"{item.ArtistName}\""); } message.AppendLine("\nIf you wish to defend your current bids against other potential higher bids, please attend the auction.\n\nThank you!"); var request = new SendPrivateMessageRequest() { AuthorName = "Art Show", Subject = title, Message = message.ToString(), RecipientUid = recipientUid, ToastTitle = "Art Show Results", ToastMessage = title }; var privateMessageId = await _privateMessageService.SendPrivateMessageAsync(request); var now = DateTime.UtcNow; foreach (var item in items) { item.PrivateMessageId = privateMessageId; item.NotificationDateTimeUtc = now; await _itemActivityRepository.ReplaceOneAsync(item); } }
public async Task CommandSendMessage() { Func <Task> c1 = null, c2 = null, c3 = null, c4 = null; var title = "Send Message"; c1 = () => AskAsync($"*{title} - Step 1 of 1*\nWhat's the attendees _registration number (including the letter at the end)_ on the badge?", async c1a => { await ClearLastAskResponseOptions(); int regNo = 0; var regNoWithLetter = c1a.Trim().ToUpper(); if (!BadgeChecksum.TryParse(regNoWithLetter, out regNo)) { await ReplyAsync($"_{regNoWithLetter} is not a valid badge number - checksum letter is missing or wrong._"); await c1(); return; } var records = (await _pushNotificationChannelRepository.FindAllAsync(a => a.Uid.StartsWith("RegSys:") && a.Uid.EndsWith($":{regNo}"))) .ToList(); if (records.Count == 0) { await ReplyAsync($"*WARNING: RegNo {regNo} is not logged in on any known device - they will receive the message when they login.*"); } c2 = () => AskAsync($"*{title} - Step 2 of 3*\nPlease specify the subject of the message.", async subject => { await ClearLastAskResponseOptions(); c3 = () => AskAsync($"*{title} - Step 3 of 3*\nPlease specify the body of the message.", async body => { await ClearLastAskResponseOptions(); var from = $"{_user.FirstName} {_user.LastName}"; c4 = () => AskAsync( $"*{title} - Review*\n\nFrom: *{from.EscapeMarkdown()}*\nTo: *{regNo}*\nSubject: *{subject.EscapeMarkdown()}*\n\nMessage:\n*{body.EscapeMarkdown()}*\n\n_Message will be placed in the users inbox and directly pushed to _*{records.Count}*_ devices._", async c4a => { if (c4a != "*send") { await c3(); return; } await _privateMessageService.SendPrivateMessageAsync(new SendPrivateMessageRequest() { AuthorName = $"{from}", RecipientUid = $"RegSys:23:{regNo}", Message = body, Subject = subject, ToastTitle = "You received a new personal message", ToastMessage = "Open the Eurofurence App to read it." }); await ReplyAsync("Message sent."); }, "Send=*send", "Cancel=/cancel"); await c4(); }, "Cancel=/cancel"); await c3(); }, "Cancel=/cancel"); await c2(); }, "Cancel=/cancel"); await c1(); }