public async Task <bool> SendInviteInSlackDM(InvitationsEntity invite) { var q = AttendStorsdagQuestion(invite); var res = await _questioner.PostMessageQuestionAsync(q); if (!res.Ok) { throw new Exception(res.Error); } return(res.Ok); }
private Question AttendStorsdagQuestion(InvitationsEntity invitationEntity) { var q = new Question() { QuestionId = invitationEntity.RowKey, Message = $"{invitationEntity.EventTopic} (CORONA EDITION! )", Recipient = invitationEntity.SlackUserId, Botname = "smartbot", Image = "https://www.fhi.no/globalassets/koronavirus-tema.png", //"https://placebeer.com/300/150", Options = new[] { new QuestionOption { Text = "Vil smittes :+1:", ActionId = RsvpActionIds.Attending, Value = RsvpValues.Attending, Style = ButtonStyles.Primary }, new QuestionOption { Text = "Håper på smitte :man-shrugging:", ActionId = RsvpActionIds.Maybe, Value = RsvpValues.Maybe }, new QuestionOption { Text = "Følger myndighetene :-1:", ActionId = RsvpActionIds.NotAttending, Value = RsvpValues.NotAttending, Style = ButtonStyles.Danger, Confirmation = new QuestionConfirmation { Title = "No va du lite smart", Text = "Sikker?", ConfirmText = "Æ e lite smart", DenyText = "Æ revurdere" } } } }; return(q); }
private async Task Invite(User user, EventEntity nextStorsdag) { var invite = new InvitationsEntity(Guid.NewGuid()) { EventId = nextStorsdag.RowKey, EventTime = nextStorsdag.EventTime, EventTopic = nextStorsdag.Topic, SlackUsername = user.Name, SlackUserId = user.Id, Rsvp = RsvpValues.Invited }; await _inviteStorage.Save(invite); var inviteSentOk = await SendInviteInSlackDM(invite); if (inviteSentOk) { _logger.LogInformation($"Sent invite {nextStorsdag.Topic} to {user.Name}"); } else { _logger.LogError($"Could not send invite {nextStorsdag.Topic} to {user.Name}"); } }