diff --git a/include/ircd/m/m.h b/include/ircd/m/m.h index a53062ec5..e0f3ce556 100644 --- a/include/ircd/m/m.h +++ b/include/ircd/m/m.h @@ -69,6 +69,7 @@ namespace ircd #include "rooms.h" #include "rooms_summary.h" #include "membership.h" +#include "push.h" #include "filter.h" #include "events.h" #include "node.h" diff --git a/include/ircd/m/name.h b/include/ircd/m/name.h index fcd46c1d9..9713246f7 100644 --- a/include/ircd/m/name.h +++ b/include/ircd/m/name.h @@ -180,4 +180,26 @@ struct ircd::m::name static constexpr const char *const filter {"filter"}; static constexpr const char *const rel_type {"rel_type"}; + + static constexpr const char *const kind {"kind"}; + static constexpr const char *const key {"key"}; + static constexpr const char *const pattern {"pattern"}; + static constexpr const char *const is {"is"}; + static constexpr const char *const cond {"cond"}; + + static constexpr const char *const actions {"actions"}; + static constexpr const char *const default_ {"default"}; + static constexpr const char *const enabled {"enabled"}; + static constexpr const char *const rule_id {"rule_id"}; + static constexpr const char *const conditions {"conditions"}; + + static constexpr const char *const override_ {"override"}; + static constexpr const char *const underride {"underride"}; + + static constexpr const char *const pushkey {"pushkey"}; + static constexpr const char *const app_id {"app_id"}; + static constexpr const char *const app_display_name {"app_display_name"}; + static constexpr const char *const profile_tag {"profile_tag"}; + static constexpr const char *const lang {"lang"}; + static constexpr const char *const append {"append"}; }; diff --git a/include/ircd/m/push.h b/include/ircd/m/push.h new file mode 100644 index 000000000..ffe35d35e --- /dev/null +++ b/include/ircd/m/push.h @@ -0,0 +1,158 @@ +// The Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2020 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +#pragma once +#define HAVE_IRCD_M_PUSH_H + +namespace ircd::m::push +{ + struct cond; + struct rule; + struct rules; + struct pusher; +} + +/// PushCondition +struct ircd::m::push::cond +:json::tuple +< + /// Required. The kind of condition to apply. See conditions for more + /// information on the allowed kinds and how they work. + json::property, + + /// Required for event_match conditions. The dot- separated field of the + /// event to match. Required for sender_notification_permission conditions. + /// The field in the power level event the user needs a minimum power level + /// for. Fields must be specified under the notifications property in the + /// power level event's content. + json::property, + + /// Required for event_match conditions. The glob-style pattern to match + /// against. Patterns with no special glob characters should be treated + /// as having asterisks prepended and appended when testing the condition. + json::property, + + /// Required for room_member_count conditions. A decimal integer optionally + /// prefixed by one of, ==, <, >, >= or <=. A prefix of < matches rooms + /// where the member count is strictly less than the given number and so + /// forth. If no prefix is present, this parameter defaults to ==. + json::property +> +{ + using super_type::tuple; + using super_type::operator=; +}; + +/// PushRule +struct ircd::m::push::rule +:json::tuple +< + /// [object or string] Required. The actions to perform when this rule is + /// matched. + json::property, + + /// Required. Whether this is a default rule, or has been set explicitly. + json::property, + + /// Required. Whether the push rule is enabled or not. + json::property, + + /// Required. The ID of this rule. + json::property, + + /// The conditions that must hold true for an event in order for a rule + /// to be applied to an event. A rule with no conditions always matches. + /// Only applicable to underride and override rules. + json::property, + + /// The glob-style pattern to match against. Only applicable to content + /// rules. + json::property +> +{ + using super_type::tuple; + using super_type::operator=; +}; + +/// 13.13.1.5 Push Ruleset +struct ircd::m::push::rules +:json::tuple +< + /// These configure behaviour for (unencrypted) messages that match + /// certain patterns. Content rules take one parameter: pattern, that + /// gives the glob pattern to match against. This is treated in the same + /// way as pattern for event_match. + json::property, + + /// The highest priority rules are user-configured overrides. + json::property, + + /// These rules change the behaviour of all messages for a given room. The + /// rule_id of a room rule is always the ID of the room that it affects. + json::property, + + /// These rules configure notification behaviour for messages from a + /// specific Matrix user ID. The rule_id of Sender rules is always the + /// Matrix user ID of the user whose messages they'd apply to. + json::property, + + /// These are identical to override rules, but have a lower priority + /// than content, room and sender rules. + json::property +> +{ + using super_type::tuple; + using super_type::operator=; +}; + +/// 13.13.1 I'm your pusher, baby. +struct ircd::m::push::pusher +:json::tuple +< + /// Required. This is a unique identifier for this pusher. See /set for + /// more detail. Max length, 512 bytes. + json::property, + + /// Required. The kind of pusher. "http" is a pusher that sends HTTP pokes. + json::property, + + /// Required. This is a reverse-DNS style identifier for the application. + /// Max length, 64 chars. + json::property, + + /// Required. A string that will allow the user to identify what + /// application owns this pusher. + json::property, + + /// Required. A string that will allow the user to identify what device owns this pusher. + json::property, + + /// This string determines which set of device specific rules this + /// pusher executes. + json::property, + + /// Required. The preferred language for receiving notifications + /// (e.g. 'en' or 'en-US') + json::property, + + /// Required. A dictionary of information for the pusher + /// implementation itself. + json::property, + + /// If true, the homeserver should add another pusher with the given + /// pushkey and App ID in addition to any others with different user IDs. + /// Otherwise, the homeserver must remove any other pushers with the same + /// App ID and pushkey for different users. The default is false. + json::property +> +{ + using super_type::tuple; + using super_type::operator=; +}; diff --git a/matrix/name.cc b/matrix/name.cc index 089382fca..08168c383 100644 --- a/matrix/name.cc +++ b/matrix/name.cc @@ -159,3 +159,25 @@ constexpr const char *const ircd::m::name::groupings; constexpr const char *const ircd::m::name::filter; constexpr const char *const ircd::m::name::rel_type; + +constexpr const char *const ircd::m::name::kind; +constexpr const char *const ircd::m::name::key; +constexpr const char *const ircd::m::name::pattern; +constexpr const char *const ircd::m::name::is; +constexpr const char *const ircd::m::name::cond; + +constexpr const char *const ircd::m::name::actions; +constexpr const char *const ircd::m::name::default_; +constexpr const char *const ircd::m::name::enabled; +constexpr const char *const ircd::m::name::rule_id; +constexpr const char *const ircd::m::name::conditions; + +constexpr const char *const ircd::m::name::override_; +constexpr const char *const ircd::m::name::underride; + +constexpr const char *const ircd::m::name::pushkey; +constexpr const char *const ircd::m::name::app_id; +constexpr const char *const ircd::m::name::app_display_name; +constexpr const char *const ircd::m::name::profile_tag; +constexpr const char *const ircd::m::name::lang; +constexpr const char *const ircd::m::name::append;