Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FriendshipResolver.cs
1using System.Globalization;
6
8{
12 public class FriendshipResolver(string BareJid, string RemoteJid, RuleRange Range) : IEventResolver
13 {
14 private readonly string bareJid = BareJid.ToLower(CultureInfo.InvariantCulture);
15 private readonly string remoteJid = RemoteJid.ToLower(CultureInfo.InvariantCulture);
16 private readonly RuleRange range = Range;
17
23 public bool Resolves(NotificationEvent Event)
24 {
25 if (Event.Type != NotificationEventType.Things || Event is not IsFriendNotificationEvent IsFriendNotificationEvent)
26 return false;
27
28 if (IsFriendNotificationEvent.BareJid != this.bareJid)
29 return false;
30
31 return this.range switch
32 {
33 RuleRange.All => true,
34 RuleRange.Domain => string.Equals(XmppClient.GetDomain(this.remoteJid), XmppClient.GetDomain(IsFriendNotificationEvent.RemoteJid), StringComparison.OrdinalIgnoreCase),
35 RuleRange.Caller => string.Equals(this.remoteJid, IsFriendNotificationEvent.RemoteJid, StringComparison.OrdinalIgnoreCase),
36 _ => false,
37 };
38 }
39 }
40}
Contains information about a request to become "friends", i.e. subscribe to presence.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:58
static string GetDomain(string JID)
Gets the domain part of a JID.
Definition: XmppClient.cs:6986
Interface for event resolvers. Such can be used to resolve multiple pending notifications at once.
Definition: ImplTypes.g.cs:58
abstract class NotificationEvent()
Abstract base class of notification events.
NotificationEventType
Button on which event is to be displayed.
RuleRange
Range of a rule change
Definition: RuleRange.cs:7