public async Task PublishDisputeCancelled(DisputeCancelledPushNotificationCommand command) { var notificationMessage = new NotificationMessage { MerchantIds = new string[] { command.NotifiedMerchantId }, Message = "Dispute cancelled." }; await _retryPolicy.ExecuteAsync(() => _pushNotificationPublisher.PublishAsync(notificationMessage)); _log.Info("Information sent to push notifications service", new { notificationMessage }); }
public async Task <IActionResult> CommentTo(long articleId, int replyToCommentId) { var article = await _articleAppService.GetArticleAsync(articleId); var reply = await ReplyToComment(replyToCommentId); // publish notification to all subscriber, exclude self await _notificationPublisher.PublishAsync(NotificationName.CommentArticle, new MessageNotificationData(Url.Action("GetArticle", "Article", new { ArticleId = articleId })), new EntityIdentifier(typeof(Blog), articleId), excludedUserIds : new[] { new UserIdentifier(AppConsts.DefaultTenant, AbpSession.GetUserId()) }); // subscribe comment notification await _notificationSubscriptionManager.SubscribeAsync( new UserIdentifier(AbpSession.TenantId, AbpSession.GetUserId()), NotificationName.CommentArticle, new EntityIdentifier(typeof(Blog), articleId)); return(View("Template/Comment/CommentTo", new CommentToViewModel { ArticleId = article.ArticleId, CommentTitle = article.Title, CommentToLink = Url.Action("GetArticle", new { ArticleId = articleId }), ReplyToCommentId = reply.Second, ReturnUrl = Url.Action("GetArticle", new { ArticleId = articleId }), ContentInit = reply.First })); }
public async Task <ActionResult> CommentTo(long solutionId, long replyToCommentId) { var solution = await _problemAppService.GetSolution(solutionId); var reply = await _articleController.ReplyToComment(replyToCommentId); // publish notification to all subscriber, exclude self await _notificationPublisher.PublishAsync(NotificationName.CommentSolution, new MessageNotificationData(Url.Action("GetSolution", new { SolutionId = solutionId })), new EntityIdentifier(typeof(ProblemSolution), solutionId), excludedUserIds : new [] { new UserIdentifier(AppConsts.DefaultTenant, AbpSession.GetUserId()) }); // subscribe comment notification await _notificationSubscriptionManager.SubscribeAsync( new UserIdentifier(AbpSession.TenantId, AbpSession.GetUserId()), NotificationName.CommentSolution, new EntityIdentifier(typeof(ProblemSolution), solutionId)); return(View("Template/Comment/CommentTo", new CommentToViewModel { ArticleId = solution.SolutionId, CommentTitle = solution.SolutionTitle, CommentToLink = Url.Action("GetSolution", new { solutionId }), ReplyToCommentId = reply.Second, ReturnUrl = Url.Action("GetSolution", new { solutionId }), ContentInit = reply.First })); }
public async Task Should_publish_general_notification() { //Arrange var notificationData = CreateNotificationData(); //Act await _notificationPublisher.PublishAsync("TestNotification", notificationData, severity : NotificationSeverity.Success); }
public async Task PublishAsync_WithoutCurrentUser_MustSendToAll() { // Arrange var recipients = CreateValidRecipientList(); // Act await publisher.PublishAsync( NotificationType.Accepted, validMessage, recipients, null, null, null); // Assert A.CallTo(() => notificationRepository.InsertAsync(A <Notification> ._)) .MustHaveHappenedTwiceExactly(); }
public async Task <ActionResult> SendNotificationTest() { var notificationData = new NotificationData { ["TestValue"] = 42 }; await _notificationPublisher.PublishAsync("TestNotification", notificationData, severity : NotificationSeverity.Success, userIds : new Guid[] { Guid.Parse("72739d63-c978-1d8c-6ce1-3a00f88efa62") }); return(Json(new { message = "发送成功" })); }
public async Task Should_Publish_General_Notification() { //Arrange var notificationData = CreateNotificationData(); //Act await _publisher.PublishAsync("TestNotification", notificationData, severity : NotificationSeverity.Success); //Assert await _store.Received() .InsertNotificationAsync( Arg.Is <NotificationInfo>( n => n.NotificationName == "TestNotification" && n.Severity == NotificationSeverity.Success && n.DataTypeName == notificationData.GetType().AssemblyQualifiedName&& n.Data.Contains("42") ) ); await _backgroundJobManager.Received() .EnqueueAsync <NotificationDistributionJob, NotificationDistributionJobArgs>( Arg.Any <NotificationDistributionJobArgs>() ); }
public virtual async Task <JsonResult> UpdateFromAoxiang(UpdateFromAoxiangViewModel input) { if (input.Password != input.PasswordAgain) { throw new UserFriendlyException("`password` should be same with `password again`"); } await _userAppService.UpdateInfoFromAoxiangAsync(new UpdateUserInfoFromAoxiangInput { Password = input.Password }); await _notificationPublisher.PublishAsync(NotificationName.CheckProfile, new MessageNotificationData(Url.Action("UserProfile")), userIds : new[] { new UserIdentifier(AppConsts.DefaultTenant, AbpSession.GetUserId()) }); return(Json(new AjaxResponse())); }
public async Task Should_Publish_General_Notification() { var notificationData = CreateNotificationData(); await _publisher.PublishAsync("TestNotification", notificationData, severity : NotificationSeverity.Success); }