diff --git a/Inotify/Controllers/SetttingSysController.cs b/Inotify/Controllers/SetttingSysController.cs index b1817ba..45a146d 100644 --- a/Inotify/Controllers/SetttingSysController.cs +++ b/Inotify/Controllers/SetttingSysController.cs @@ -120,7 +120,7 @@ namespace Inotify.Controllers public IActionResult GetSendInfos(string? start, string? end) { var templates = SendTaskManager.Instance.GetInputTemeplates(); - var sendInfos = DBManager.Instance.DBase.Fetch(); + var sendInfos = DBManager.Instance.DBase.Fetch().Where(e=>!string.IsNullOrEmpty( e.TemplateID)).ToList(); var sendInfoQuerys = sendInfos.Where(e => int.Parse(e.Date) >= int.Parse(start) && int.Parse(e.Date) <= int.Parse(end)).ToList(); var sendInfoGroups = sendInfoQuerys.GroupBy(e => e.Date).Select(e => new { date = e.Key, count = e.Sum(item => item.Count) }).ToList(); var sendTypeInfoGroups = sendInfoQuerys.GroupBy(e => e.TemplateID).Select(e => new { date = e.Key, count = e.Sum(item => item.Count) }).ToList(); diff --git a/Inotify/Data/DBManager.cs b/Inotify/Data/DBManager.cs index 034ce5b..03a537d 100644 --- a/Inotify/Data/DBManager.cs +++ b/Inotify/Data/DBManager.cs @@ -164,17 +164,10 @@ namespace Inotify.Data return DBase.Query().FirstOrDefault(e => e.UserName == userName); } - public string GetSendAuthInfo(string token, out string guid) + public string GetSendAuthInfo(string key, out string guid) { - guid = string.Empty; - var upToekn = token.ToUpper(); - var userInfo = DBManager.Instance.DBase.Query().FirstOrDefault(e => e.Token == upToekn && e.Active); - if (userInfo == null) - { - return null; - } - - var authInfo = DBManager.Instance.DBase.Query().FirstOrDefault(e => e.Id == userInfo.SendAuthId && e.UserId == userInfo.Id); + guid = null; + var authInfo = DBManager.Instance.DBase.Query().FirstOrDefault(e => e.Key== key.ToUpper()); if (authInfo == null) { return null; diff --git a/Inotify/Inotify.csproj b/Inotify/Inotify.csproj index bab38da..776f6ef 100644 --- a/Inotify/Inotify.csproj +++ b/Inotify/Inotify.csproj @@ -6,8 +6,8 @@ Linux Inotify.Program enable - 2.0.0.4 - 2.0.0.4 + 2.1.0.0 + 2.1.0.0 @@ -18,7 +18,6 @@ - diff --git a/Inotify/Sends/Products/BarkSendTemplate.cs b/Inotify/Sends/Products/BarkSendTemplate.cs index f54529b..9007fc1 100644 --- a/Inotify/Sends/Products/BarkSendTemplate.cs +++ b/Inotify/Sends/Products/BarkSendTemplate.cs @@ -1,13 +1,7 @@ using CorePush.Apple; -using Jose; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; -using System.Collections.Generic; -using System.Linq; using System.Net.Http; -using System.Security.Cryptography; -using System.Text; namespace Inotify.Sends.Products { @@ -32,52 +26,50 @@ namespace Inotify.Sends.Products [InputTypeAttribte(6, "SendUrl", "SendUrl", "SendUrl", true, true)] public string SendUrl { get; set; } - } [SendMethodKey("3B6DE04D-A9EF-4C91-A151-60B7425C5AB2", "Bark", Order = 2999, Waring = "BARK通道勿手动添加,请使用APP添加BARK地址绑定")] public class BarkSendTemplate : SendTemplate { - private static string KeyID; - - private static string TeamID; - private static ApnSender apnSender; public override bool SendMessage(SendMessage message) { if (apnSender == null) { - KeyID = SendCacheStore.GetSystemValue("barkKeyId"); - TeamID = SendCacheStore.GetSystemValue("barkTeamId"); + var keyID = SendCacheStore.GetSystemValue("barkKeyId"); + var teamID = SendCacheStore.GetSystemValue("barkTeamId"); var privateKey = SendCacheStore.GetSystemValue("barkPrivateKey"); var privateKeyContent = privateKey.Split('\n')[1]; - var decodeKey = Convert.FromBase64String(privateKeyContent); var apnSettings = new ApnSettings() { - TeamId = TeamID, + TeamId = teamID, AppBundleIdentifier = "me.fin.bark", P8PrivateKey = privateKeyContent, ServerType = ApnServerType.Production, - P8PrivateKeyId = KeyID, + P8PrivateKeyId = keyID, }; apnSender = new ApnSender(apnSettings, new HttpClient()); } - var payload = new AppleNotification( Guid.NewGuid(), message.Data, - message.Title); + message.Title) + { + IsArchive = Auth.IsArchive, + AutoMaticallyCopy=Auth.AutoMaticallyCopy, + }; + payload.Aps.Sound = Auth.Sound; + var response = apnSender.Send(payload, Auth.DeviceToken); if (response.IsSuccess) return true; return false; } - } public class AppleNotification @@ -91,8 +83,12 @@ namespace Inotify.Sends.Products [JsonProperty("body")] public string Body { get; set; } + } + [JsonProperty("sound")] + public string Sound { get; set; } + [JsonProperty("alert")] public Alert AlertBody { get; set; } @@ -119,5 +115,11 @@ namespace Inotify.Sends.Products [JsonProperty("id")] public Guid Id { get; set; } + + [JsonProperty("isarchive")] + public string IsArchive { get; set; } + + [JsonProperty("automaticallycopy")] + public string AutoMaticallyCopy { get; set; } } } diff --git a/Inotify/Sends/SendMessage.cs b/Inotify/Sends/SendMessage.cs index a6d2398..652c358 100644 --- a/Inotify/Sends/SendMessage.cs +++ b/Inotify/Sends/SendMessage.cs @@ -2,9 +2,24 @@ { public class SendMessage { + public SendMessage() + { + + } + + public SendMessage(SendMessage sendMessage) + { + Token = sendMessage.Token; + Title = sendMessage.Title; + Data = sendMessage.Data; + Key = sendMessage.Key; + + } public string Token; public string Title; public string? Data; public string? Key; } + + } diff --git a/Inotify/Sends/SendTaskManager.cs b/Inotify/Sends/SendTaskManager.cs index 2eb15a7..0d1700d 100644 --- a/Inotify/Sends/SendTaskManager.cs +++ b/Inotify/Sends/SendTaskManager.cs @@ -178,15 +178,17 @@ namespace Inotify.Sends var result = sendMessageMethod.Invoke(sendMethodTemplateActor, new object[] { message }); if (result != null) { - m_analyseMessages.Add(message); + var logMessage = new SendMessage(message); + logMessage.Key = authInfo.Key; + m_analyseMessages.Add(logMessage); if ((bool)result) { - OnSendSucessed?.Invoke(this, message); + OnSendSucessed?.Invoke(this, logMessage); continue; } else { - OnSendFailed?.Invoke(this, message); + OnSendFailed?.Invoke(this, logMessage); } } @@ -213,7 +215,7 @@ namespace Inotify.Sends { var message = m_analyseMessages.Take(); var date = DateTime.Now.ToString("yyyyMMdd"); - var authData = DBManager.Instance.GetSendAuthInfo(message.Token, out string temeplateId); + var authData = DBManager.Instance.GetSendAuthInfo(message.Key, out string temeplateId); if (temeplateId != null) {