21 private readonly Dictionary<PushMessagingService, string> tokens = [];
22 private DateTime lastTokenCheck = DateTime.MinValue;
72 return this.tokens.TryGetValue(Source, out
Token);
81 return (DateTime.UtcNow.Subtract(ReportDate).TotalDays > 7) || (TokenInformation.Token != OldToken);
92 DateTime Now = DateTime.Now;
96 Now.Subtract(
this.lastTokenCheck).TotalHours >= 1)
98 this.lastTokenCheck = Now;
109 string Version = AppInfo.VersionString +
"." + AppInfo.BuildString;
111 bool IsVersionChanged = Version != PrevVersion;
113 if (IsVersionChanged || ForceReport)
117 if (!
string.IsNullOrEmpty(
Token))
128 if (IsVersionChanged)
134 #region Message Rules
138 StringBuilder Content =
new();
140 Content.Append(
"FromJid:=GetAttribute(Stanza,'from');");
141 Content.Append(
"ToJid:=GetAttribute(Stanza,'to');");
142 Content.Append(
"FriendlyName:=RosterName(ToJid,FromJid);");
143 Content.Append(
"Content:=GetElement(Stanza,'content');");
144 Content.Append(
"{'myTitle':'");
146 Content.Append(
" ' + FriendlyName,");
147 Content.Append(
"'myBody':InnerText(GetElement(Stanza,'body')),");
148 Content.Append(
"'fromJid':FromJid,");
149 Content.Append(
"'rosterName':FriendlyName,");
151 Content.Append(
"'isObject':exists(Content) and !empty(Markdown:= InnerText(Content)) and (Left(Markdown,2)='![' or (Left(Markdown,3)='```' and Right(Markdown,3)='```')),");
152 Content.Append(
"'channelId':'");
154 Content.Append(
"',");
155 Content.Append(
"'content_available':true}");
167 Content.Append(
"E:=GetElement(Stanza,'petitionIdentityMsg');");
168 Content.Append(
"ToJid:=GetAttribute(Stanza,'to');");
169 Content.Append(
"FromJid:=GetAttribute(E,'from');");
170 Content.Append(
"FriendlyName:=RosterName(ToJid,FromJid);");
171 Content.Append(
"{'myTitle':'");
173 Content.Append(
" ' + FriendlyName,");
174 Content.Append(
"'myBody':GetAttribute(E,'purpose'),");
175 Content.Append(
"'fromJid':FromJid,");
176 Content.Append(
"'rosterName':FriendlyName,");
177 Content.Append(
"'channelId':'");
179 Content.Append(
"',");
180 Content.Append(
"'content_available':true}");
188 Content.Append(
"E:=GetElement(Stanza,'petitionContractMsg');");
189 Content.Append(
"ToJid:=GetAttribute(Stanza,'to');");
190 Content.Append(
"FromJid:=GetAttribute(E,'from');");
191 Content.Append(
"FriendlyName:=RosterName(ToJid,FromJid);");
192 Content.Append(
"{'myTitle':'");
194 Content.Append(
" ' + FriendlyName,");
195 Content.Append(
"'myBody':GetAttribute(E,'purpose'),");
196 Content.Append(
"'fromJid':FromJid,");
197 Content.Append(
"'rosterName':FriendlyName,");
198 Content.Append(
"'channelId':'");
200 Content.Append(
"',");
201 Content.Append(
"'content_available':true}");
209 Content.Append(
"E:=GetElement(Stanza,'petitionSignatureMsg');");
210 Content.Append(
"ToJid:=GetAttribute(Stanza,'to');");
211 Content.Append(
"FromJid:=GetAttribute(E,'from');");
212 Content.Append(
"FriendlyName:=RosterName(ToJid,FromJid);");
213 Content.Append(
"{'myTitle':'");
215 Content.Append(
" ' + FriendlyName,");
216 Content.Append(
"'myBody':GetAttribute(E,'purpose'),");
217 Content.Append(
"'fromJid':FromJid,");
218 Content.Append(
"'rosterName':FriendlyName,");
219 Content.Append(
"'channelId':'");
221 Content.Append(
"',");
222 Content.Append(
"'content_available':true}");
234 Content.Append(
"E:=GetElement(Stanza,'identity');");
235 Content.Append(
"{'myTitle':'");
237 Content.Append(
"',");
238 Content.Append(
"'legalId':GetAttribute(E,'id'),");
239 Content.Append(
"'channelId':'");
241 Content.Append(
"',");
242 Content.Append(
"'content_available':true}");
254 Content.Append(
"E:=GetElement(Stanza,'contractCreated');");
255 Content.Append(
"{'myTitle':'");
257 Content.Append(
"',");
258 Content.Append(
"'contractId':GetAttribute(E,'contractId'),");
259 Content.Append(
"'channelId':'");
261 Content.Append(
"',");
262 Content.Append(
"'content_available':true}");
270 Content.Append(
"E:=GetElement(Stanza,'contractSigned');");
271 Content.Append(
"{'myTitle':'");
273 Content.Append(
"',");
274 Content.Append(
"'contractId':GetAttribute(E,'contractId'),");
275 Content.Append(
"'legalId':GetAttribute(E,'legalId'),");
276 Content.Append(
"'channelId':'");
278 Content.Append(
"',");
279 Content.Append(
"'content_available':true}");
287 Content.Append(
"E:=GetElement(Stanza,'contractUpdated');");
288 Content.Append(
"{'myTitle':'");
290 Content.Append(
"',");
291 Content.Append(
"'contractId':GetAttribute(E,'contractId'),");
292 Content.Append(
"'channelId':'");
294 Content.Append(
"',");
295 Content.Append(
"'content_available':true}");
303 Content.Append(
"E:=GetElement(Stanza,'contractDeleted');");
304 Content.Append(
"{'myTitle':'");
306 Content.Append(
"',");
307 Content.Append(
"'contractId':GetAttribute(E,'contractId'),");
308 Content.Append(
"'channelId':'");
310 Content.Append(
"',");
311 Content.Append(
"'content_available':true}");
319 Content.Append(
"E:=GetElement(Stanza,'contractProposal');");
320 Content.Append(
"{'myTitle':'");
322 Content.Append(
"',");
323 Content.Append(
"'myBody':GetAttribute(E,'message'),");
324 Content.Append(
"'contractId':Num(GetAttribute(E,'contractId')),");
325 Content.Append(
"'role':Num(GetAttribute(E,'role')),");
326 Content.Append(
"'channelId':'");
328 Content.Append(
"',");
329 Content.Append(
"'content_available':true}");
341 Content.Append(
"E:=GetElement(Stanza,'balance');");
342 Content.Append(
"{'myTitle':'");
344 Content.Append(
"',");
345 Content.Append(
"'amount':Num(GetAttribute(E,'amount')),");
346 Content.Append(
"'currency':GetAttribute(E,'currency'),");
347 Content.Append(
"'timestamp':DateTime(GetAttribute(E,'timestamp')),");
348 Content.Append(
"'channelId':'");
350 Content.Append(
"',");
351 Content.Append(
"'content_available':true}");
358 #region Neuro-Features
363 Content.Append(
"E:=GetElement(Stanza,'tokenAdded');");
364 Content.Append(
"E2:=GetElement(E,'token');");
365 Content.Append(
"{'myTitle':'");
367 Content.Append(
"',");
368 Content.Append(
"'myBody':GetAttribute(E2,'friendlyName'),");
369 Content.Append(
"'value':Num(GetAttribute(E2,'value')),");
370 Content.Append(
"'currency':GetAttribute(E2,'currency'),");
371 Content.Append(
"'channelId':'");
373 Content.Append(
"',");
374 Content.Append(
"'content_available':true}");
382 Content.Append(
"E:=GetElement(Stanza,'tokenRemoved');");
383 Content.Append(
"E2:=GetElement(E,'token');");
384 Content.Append(
"{'myTitle':'");
386 Content.Append(
"',");
387 Content.Append(
"'myBody':GetAttribute(E2,'friendlyName'),");
388 Content.Append(
"'value':Num(GetAttribute(E2,'value')),");
389 Content.Append(
"'currency':GetAttribute(E2,'currency'),");
390 Content.Append(
"'channelId':'");
392 Content.Append(
"',");
393 Content.Append(
"'content_available':true}");
405 Content.Append(
"ToJid:=GetAttribute(Stanza,'to');");
406 Content.Append(
"E:=GetElement(Stanza,'isFriend');");
407 Content.Append(
"RemoteJid:=GetAttribute(E,'remoteJid');");
408 Content.Append(
"{'myTitle':'");
410 Content.Append(
"',");
411 Content.Append(
"'myBody':RosterName(ToJid,RemoteJid),");
412 Content.Append(
"'remoteJid':RemoteJid,");
413 Content.Append(
"'jid':GetAttribute(E,'jid'),");
414 Content.Append(
"'key':GetAttribute(E,'key'),");
415 Content.Append(
"'q':'isFriend',");
416 Content.Append(
"'channelId':'");
418 Content.Append(
"',");
419 Content.Append(
"'content_available':true}");
427 Content.Append(
"ToJid:=GetAttribute(Stanza,'to');");
428 Content.Append(
"E:=GetElement(Stanza,'canRead');");
429 Content.Append(
"RemoteJid:=GetAttribute(E,'remoteJid');");
430 Content.Append(
"{'myTitle':'");
432 Content.Append(
"',");
433 Content.Append(
"'myBody':RosterName(ToJid,RemoteJid),");
434 Content.Append(
"'remoteJid':RemoteJid,");
435 Content.Append(
"'jid':GetAttribute(E,'jid'),");
436 Content.Append(
"'key':GetAttribute(E,'key'),");
437 Content.Append(
"'q':'canRead',");
438 Content.Append(
"'channelId':'");
440 Content.Append(
"',");
441 Content.Append(
"'content_available':true}");
449 Content.Append(
"ToJid:=GetAttribute(Stanza,'to');");
450 Content.Append(
"E:=GetElement(Stanza,'canControl');");
451 Content.Append(
"RemoteJid:=GetAttribute(E,'remoteJid');");
452 Content.Append(
"{'myTitle':'");
454 Content.Append(
"',");
455 Content.Append(
"'myBody':RosterName(ToJid,RemoteJid),");
456 Content.Append(
"'remoteJid':RemoteJid,");
457 Content.Append(
"'jid':GetAttribute(E,'jid'),");
458 Content.Append(
"'key':GetAttribute(E,'key'),");
459 Content.Append(
"'q':'canControl',");
460 Content.Append(
"'channelId':'");
462 Content.Append(
"',");
463 Content.Append(
"'content_available':true}");
const string NamespaceEDaler
Namespace of eDaler component.
const string Provisioning
Provisioning channel
const string Petitions
Petitions channel
const string Identities
Identities channel
const string Messages
Messages channel
const string EDaler
eDaler channel
const string Tokens
Tokens channel
const string Contracts
Contracts channel
Runtime setting key names.
const string PushNotificationConfigurationVersion
Push-notification configuration version.
const string PushNotificationReportDate
When push-notification token was reported.
const string PushNotificationToken
Push-notification token.
A set of never changing property constants and helpful values.
Push notification service
async Task CheckPushNotificationToken(TokenInformation? TokenInformation)
Checks if the Push Notification Token is current and registered properly.
bool TryGetToken(PushMessagingService Source, out string? Token)
Tries to get a token from a push notification service.
TokenEventHandler? OnNewToken
Event raised when a new token is made available.
PushNotificationService()
Push notification service
async Task NewToken(TokenInformation TokenInformation)
New token received from push notification back-end.
Event argumens for token-based events.
Base class that references services in the app.
static ILogService LogService
Log service.
static IStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
const string NamespaceNeuroFeatures
Namespace for Neuro-Features.
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
Adds support for legal identities, smart contracts and signatures to an XMPP client.
const string NamespaceSmartContractsCurrent
Current namespce for smart contracts.
const string NamespaceLegalIdentitiesCurrent
Current namespace for legal identities.
Implements an XMPP provisioning client interface.
const string NamespaceProvisioningOwnerCurrent
Current namespace for provisioning by owners.
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
static async Task< bool > SetAsync(string Key, string Value)
Sets a string-valued setting.
Interface for push notification services.
delegate Task TokenEventHandler(object? Sender, TokenEventArgs e)
Delegate for token event handlers.
ClientType
Type of client requesting notification.
PushMessagingService
Push messaging service used.
MessageType
Type of message received.