routing

package
v0.0.0-...-9835270 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2021 License: AGPL-3.0, Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseContentRules = func() []pushapitypes.PushRule {
	pushRules := []pushapitypes.PushRule{
		{
			RuleId:  "global/content/.m.rule.contains_user_name",
			Default: true,
			Enabled: false,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "content.body",
					Pattern: "user_localpart",
				},
			},
			Actions: GetAction2(),
		},
	}
	return pushRules
}
View Source
var BaseOverrideRules = func() []pushapitypes.PushRule {
	pushRules := []pushapitypes.PushRule{
		{
			RuleId:  "global/override/.m.rule.suppress_notices",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "content.msgtype",
					Pattern: "m.notice",
				},
			},
			Actions: GetAction(),
		},
		{
			RuleId:  "global/override/.m.rule.invite_for_me",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "type",
					Pattern: "m.room.member",
				},
				{
					Kind:    "event_match",
					Key:     "content.membership",
					Pattern: "invite",
				},
				{
					Kind:    "event_match",
					Key:     "state_key",
					Pattern: "user_id",
				},
			},
			Actions: GetAction1(),
		},
		{
			RuleId:  "global/override/.m.rule.member_event",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "type",
					Pattern: "m.room.member",
				},
			},
			Actions: GetAction(),
		},
		{
			RuleId:  "global/override/.m.rule.signals",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "content.msgtype",
					Pattern: "m.alert",
				},
				{
					Kind: "signal",
				},
			},
			Actions: GetAction2(),
		},
		{
			RuleId:  "global/override/.m.rule.contains_display_name",
			Default: true,
			Enabled: false,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind: "contains_display_name",
				},
			},
			Actions: GetAction2(),
		},
	}
	return pushRules
}
View Source
var BasePreOverrideRules = func() []pushapitypes.PushRule {
	pushRule := pushapitypes.PushRule{
		RuleId:  "global/override/.m.rule.master",
		Default: true,
		Enabled: false,
		Actions: GetAction(),
	}
	pushRule.Conditions = []pushapitypes.PushCondition{}
	pushRules := []pushapitypes.PushRule{pushRule}
	return pushRules
}
View Source
var BaseRuleIds = func() map[string]string {
	rules := map[string]string{
		"global/override/.m.rule.master":                "override",
		"global/override/.m.rule.suppress_notices":      "override",
		"global/override/.m.rule.invite_for_me":         "override",
		"global/override/.m.rule.member_event":          "override",
		"global/override/.m.rule.signals":               "override",
		"global/override/.m.rule.contains_display_name": "override",
		"global/content/.m.rule.contains_user_name":     "content",
		"global/underride/.m.rule.call":                 "underride",
		"global/underride/.m.rule.room_one_to_one":      "underride",
		"global/underride/.m.rule.message":              "underride",
		"global/underride/.m.rule.video":                "underride",
		"global/underride/.m.rule.encrypted":            "underride",
	}
	return rules
}
View Source
var BaseUnderRideRules = func() []pushapitypes.PushRule {
	pushRules := []pushapitypes.PushRule{
		{
			RuleId:  "global/underride/.m.rule.call",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "type",
					Pattern: "m.call.invite",
				},
			},
			Actions: GetAction4(),
		},
		{
			RuleId:  "global/underride/.m.rule.room_one_to_one",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind: "room_member_count",
					Is:   "2",
				},
			},
			Actions: GetAction1(),
		},
		{
			RuleId:  "global/underride/.m.rule.message",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "type",
					Pattern: "m.room.message",
				},
			},
			Actions: GetAction6(),
		},
		{
			RuleId:  "global/underride/.m.rule.encrypted",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "type",
					Pattern: "m.room.encrypted",
				},
			},
			Actions: GetAction5(),
		},
		{
			RuleId:  "global/underride/.m.rule.video",
			Default: true,
			Enabled: true,
			Conditions: []pushapitypes.PushCondition{
				{
					Kind:    "event_match",
					Key:     "type",
					Pattern: "m.modular.video",
				},
				{
					Kind:    "event_match",
					Key:     "content.data.isCreate",
					Pattern: "true",
				},
			},
			Actions: GetAction5(),
		},
	}
	return pushRules
}
View Source
var GetAction = func() []interface{} {
	var actions []interface{}
	actions = append(actions, "dont_notify")
	return actions
}
View Source
var GetAction1 = func() []interface{} {
	var actions []interface{}
	actions = append(actions, "notify")
	tweaks := []pushapitypes.Tweak{
		{
			SetTweak: "sound",
			Value:    "default",
		},
		{
			SetTweak: "highlight",
			Value:    false,
		},
	}

	for _, v := range tweaks {
		actions = append(actions, v)
	}
	return actions
}
View Source
var GetAction2 = func() []interface{} {
	var actions []interface{}
	actions = append(actions, "notify")
	tweaks := []pushapitypes.Tweak{
		{
			SetTweak: "sound",
			Value:    "default",
		},
		{
			SetTweak: "highlight",
		},
	}

	for _, v := range tweaks {
		actions = append(actions, v)
	}
	return actions
}
View Source
var GetAction3 = func() []interface{} {
	var actions []interface{}
	actions = append(actions, "notify")
	tweaks := []pushapitypes.Tweak{
		{
			SetTweak: "sound",
			Value:    "default",
		},
	}

	for _, v := range tweaks {
		actions = append(actions, v)
	}
	return actions
}
View Source
var GetAction4 = func() []interface{} {
	var actions []interface{}
	actions = append(actions, "notify")
	tweaks := []pushapitypes.Tweak{
		{
			SetTweak: "sound",
			Value:    "ring",
		},
		{
			SetTweak: "highlight",
			Value:    false,
		},
	}

	for _, v := range tweaks {
		actions = append(actions, v)
	}
	return actions
}
View Source
var GetAction5 = func() []interface{} {
	var actions []interface{}
	actions = append(actions, "notify")
	tweaks := []pushapitypes.Tweak{
		{
			SetTweak: "highlight",
			Value:    false,
		},
	}

	for _, v := range tweaks {
		actions = append(actions, v)
	}
	return actions
}
View Source
var GetAction6 = func() []interface{} {
	var actions []interface{}
	actions = append(actions, "notify")
	tweaks := []pushapitypes.Tweak{
		{
			SetTweak: "sound",
			Value:    "default",
		},
	}

	for _, v := range tweaks {
		actions = append(actions, v)
	}
	return actions
}

Functions

func AddRules

func AddRules(kind string, rule pushapitypes.PushRule, rules pushapitypes.Rules) pushapitypes.Rules

func CheckPusherBody

func CheckPusherBody(pushers *external.PostSetPushersRequest) string

func ConvertConditions

func ConvertConditions(userID, kind string, pushRule pushapitypes.PushRule, forRequest bool) pushapitypes.PushRule

func ConvertPushRule

func ConvertPushRule(data pushapitypes.PushRuleCacheData, defaultRule bool) (pushapitypes.PushRule, error)

func DeletePushRule

func DeletePushRule(
	ctx context.Context,
	pushDB model.PushAPIDatabase,
	device *authtypes.Device,
	cfg config.Dendrite,
	scope string,
	kind string,
	ruleID string,
	cache service.Cache,
) (int, core.Coder)

DeletePushrule implements DELETE /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}

func FormatRuleId

func FormatRuleId(
	kind string,
	ruleID string,
) string

func FormatRuleResponse

func FormatRuleResponse(rules pushapitypes.Rules) pushapitypes.RuleSet

func FormatRules

func FormatRules(userID string, cache service.Cache, global pushapitypes.Rules, forRequest bool) pushapitypes.Rules

func GetBasePushRule

func GetBasePushRule(ruleID string) pushapitypes.PushRule

func GetKindFromRuleId

func GetKindFromRuleId(ruleID string) string

func GetOriginalRuleId

func GetOriginalRuleId(ruleID string) string

func GetPushRule

func GetPushRule(
	ctx context.Context,
	device *authtypes.Device,
	scope string,
	kind string,
	ruleID string,
	cache service.Cache,
) (int, core.Coder)

GetPushrule implements GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}

func GetPushRuleActions

func GetPushRuleActions(
	ctx context.Context,
	device *authtypes.Device,
	scope string,
	kind string,
	ruleID string,
	cache service.Cache,
) (int, core.Coder)

GetPushruleActions implements GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions

func GetPushRuleEnabled

func GetPushRuleEnabled(
	ctx context.Context,
	device *authtypes.Device,
	scope string,
	kind string,
	ruleID string,
	cache service.Cache,
) (int, core.Coder)

GetPushruleEnabled implements GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled

func GetPushRules

func GetPushRules(
	device *authtypes.Device,
	cache service.Cache,
) (int, core.Coder)

GetPushrule implements GET /_matrix/client/r0/pushrules

func GetPushRulesGlobal

func GetPushRulesGlobal(
	device *authtypes.Device,
	cache service.Cache,
) (int, core.Coder)

GetPushrule implements GET /_matrix/client/r0/pushrules/global/

func GetPushers

func GetPushers(
	userID string,
	cache service.Cache,
) (int, core.Coder)

GetPushers implements GET /_matrix/client/r0/pushers

func GetPushersByName

func GetPushersByName(userID string, cache service.Cache, forRequest bool) pushapitypes.Pushers

func GetRuleEnabled

func GetRuleEnabled(userName, ruleID string, cache service.Cache) bool

func GetUserPushRules

func GetUserPushRules(userID string, cache service.Cache, forRequest bool) (global pushapitypes.Rules)

func GetUsersPushers

func GetUsersPushers(
	users *external.PostUsersPushKeyRequest,
	cache service.Cache,
) (int, core.Coder)

GetUsersPushers implements POST /_matrix/client/r0/users/pushkey

func MakeBaseAppendRule

func MakeBaseAppendRule(kind string, modified map[string]pushapitypes.PushRuleCacheData) []pushapitypes.PushRule

func MakeBasePreAppendRule

func MakeBasePreAppendRule(kind string, modified map[string]pushapitypes.PushRuleCacheData) []pushapitypes.PushRule

func PutPushRule

func PutPushRule(
	ctx context.Context,
	pushRule *external.PutPushrulesByIDRequest,
	pushDB model.PushAPIDatabase,
	device *authtypes.Device,
	cfg config.Dendrite,
	scope string,
	kind string,
	ruleID string,
	cache service.Cache,
) (int, core.Coder)

PutPushrule implements PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}

func PutPushRuleActions

func PutPushRuleActions(
	ctx context.Context,
	actions *external.PutPushrulesActionsByIDRequest,
	pushDB model.PushAPIDatabase,
	device *authtypes.Device,
	cfg config.Dendrite,
	scope string,
	kind string,
	ruleID string,
	cache service.Cache,
) (int, core.Coder)

PutPushruleActions implements PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions

func PutPushRuleEnabled

func PutPushRuleEnabled(
	ctx context.Context,
	enabled *external.PutPushrulesEnabledByIDRequest,
	pushDB model.PushAPIDatabase,
	device *authtypes.Device,
	cfg config.Dendrite,
	scope string,
	kind string,
	ruleID string,
	cache service.Cache,
) (int, core.Coder)

PutPushruleEnabled implements PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled

func PutPusher

func PutPusher(
	ctx context.Context,
	pushers *external.PostSetPushersRequest,
	pushDB model.PushAPIDatabase,
	device *authtypes.Device,
) (int, core.Coder)

PutPushers implements POST /_matrix/client/r0/pushers/set

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL