protected virtual async Task SendWeChatTemplateMessagAsync(NotificationInfo notification, UserIdentifier identifier) { var templateId = GetOrDefaultTemplateId(notification.Data); Logger.LogDebug($"Get wechat weapp template id: {templateId}"); var redirect = GetOrDefault(notification.Data, "RedirectPage", null); Logger.LogDebug($"Get wechat weapp redirect page: {redirect ?? "null"}"); var weAppState = GetOrDefault(notification.Data, "WeAppState", Options.DefaultWeAppState); Logger.LogDebug($"Get wechat weapp state: {weAppState ?? null}"); var weAppLang = GetOrDefault(notification.Data, "WeAppLanguage", Options.DefaultWeAppLanguage); Logger.LogDebug($"Get wechat weapp language: {weAppLang ?? null}"); var weChatWeAppNotificationData = new WeChatWeAppSendNotificationData(identifier.UserName, templateId, redirect, weAppState, weAppLang); // 写入模板数据 weChatWeAppNotificationData.WriteStandardData(NotificationData.ToStandardData(Options.DefaultMsgPrefix, notification.Data)); Logger.LogDebug($"Sending wechat weapp notification: {notification.Name}"); // 发送小程序订阅消息 await NotificationSender.SendAsync(weChatWeAppNotificationData); }
protected virtual async Task SendWeChatTemplateMessagAsync(NotificationInfo notification, UserIdentifier identifier, CancellationToken cancellationToken = default) { var templateId = GetOrDefaultTemplateId(notification.Data); if (templateId.IsNullOrWhiteSpace()) { Logger.LogWarning("Wechat weapp template id be empty, can not send notification!"); return; } Logger.LogDebug($"Get wechat weapp template id: {templateId}"); var redirect = GetOrDefault(notification.Data, "RedirectPage", null); Logger.LogDebug($"Get wechat weapp redirect page: {redirect ?? "null"}"); var weAppState = GetOrDefault(notification.Data, "WeAppState", Options.DefaultWeAppState); Logger.LogDebug($"Get wechat weapp state: {weAppState ?? null}"); var weAppLang = GetOrDefault(notification.Data, "WeAppLanguage", Options.DefaultWeAppLanguage); Logger.LogDebug($"Get wechat weapp language: {weAppLang ?? null}"); // TODO: 如果微信端发布通知,请组装好 openid 字段在通知数据内容里面 string weChatCode = GetOrDefault(notification.Data, AbpWeChatClaimTypes.OpenId, ""); var openId = !weChatCode.IsNullOrWhiteSpace() ? weChatCode : await UserWeChatOpenIdFinder.FindByUserIdAsync(identifier.UserId); var weChatWeAppNotificationData = new WeChatWeAppSendNotificationData(openId, templateId, redirect, weAppState, weAppLang); // 写入模板数据 weChatWeAppNotificationData.WriteStandardData(NotificationData.ToStandardData(Options.DefaultMsgPrefix, notification.Data)); Logger.LogDebug($"Sending wechat weapp notification: {notification.Name}"); // 发送小程序订阅消息 await NotificationSender.SendAsync(weChatWeAppNotificationData); }