diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-03-23 14:44:36 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-03-23 14:44:36 +0200 |
commit | 03e9a0d5ac5329a6e74f3e3bf34ef590c863a6d3 (patch) | |
tree | de6c068cf050ba331761a9b61819dfc89e18391e /matrix/pushrules | |
parent | 7cc55ade3060ee71c4ae38462a27bf92d6c2c932 (diff) |
Documentation and refactoring
Diffstat (limited to 'matrix/pushrules')
-rw-r--r-- | matrix/pushrules/ruleset.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/matrix/pushrules/ruleset.go b/matrix/pushrules/ruleset.go index b533f94..f3026c8 100644 --- a/matrix/pushrules/ruleset.go +++ b/matrix/pushrules/ruleset.go @@ -39,6 +39,14 @@ type rawPushRuleset struct { Underride PushRuleArray `json:"underride"` } +// UnmarshalJSON parses JSON into this PushRuleset. +// +// For override, sender and underride push rule arrays, the type is added +// to each PushRule and the array is used as-is. +// +// For room and sender push rule arrays, the type is added to each PushRule +// and the array is converted to a map with the rule ID as the key and the +// PushRule as the value. func (rs *PushRuleset) UnmarshalJSON(raw []byte) (err error) { data := rawPushRuleset{} err = json.Unmarshal(raw, &data) @@ -54,6 +62,7 @@ func (rs *PushRuleset) UnmarshalJSON(raw []byte) (err error) { return } +// MarshalJSON is the reverse of UnmarshalJSON() func (rs *PushRuleset) MarshalJSON() ([]byte, error) { data := rawPushRuleset{ Override: rs.Override, |