mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -81,6 +81,9 @@ env_gateway_base_config() ->
|
||||
<<"push_clear_notifications_enabled">> => env_bool(
|
||||
"FLUXER_GATEWAY_PUSH_CLEAR_NOTIFICATIONS_ENABLED", true
|
||||
),
|
||||
<<"push_enrolled_clear_notifications_enabled">> => env_bool(
|
||||
"FLUXER_GATEWAY_PUSH_ENROLLED_CLEAR_NOTIFICATIONS_ENABLED", true
|
||||
),
|
||||
<<"push_endpoint_guard_enabled">> => env_bool(
|
||||
"FLUXER_GATEWAY_PUSH_ENDPOINT_GUARD_ENABLED", true
|
||||
),
|
||||
@@ -259,6 +262,9 @@ build_push_config(Service, Public) ->
|
||||
push_clear_notifications_enabled => get_bool(
|
||||
Service, <<"push_clear_notifications_enabled">>, true
|
||||
),
|
||||
push_enrolled_clear_notifications_enabled => get_bool(
|
||||
Service, <<"push_enrolled_clear_notifications_enabled">>, true
|
||||
),
|
||||
push_endpoint_guard_enabled => get_bool(
|
||||
Service, <<"push_endpoint_guard_enabled">>, true
|
||||
),
|
||||
|
||||
@@ -246,7 +246,9 @@ clear_channel_notifications(UserId, ChannelId, MessageId) ->
|
||||
-spec clear_for_enrolment(boolean(), integer(), integer(), integer()) -> ok.
|
||||
clear_for_enrolment(true, UserId, ChannelId, MessageId) ->
|
||||
ok = push_outbox:truncate_read(UserId, ChannelId, MessageId),
|
||||
cast_clear_if_enabled(clear_notifications_enabled(), UserId, ChannelId, MessageId);
|
||||
cast_clear_if_enabled(
|
||||
enrolled_clear_notifications_enabled(), UserId, ChannelId, MessageId
|
||||
);
|
||||
clear_for_enrolment(false, UserId, ChannelId, MessageId) ->
|
||||
cast_clear_if_enabled(clear_notifications_enabled(), UserId, ChannelId, MessageId).
|
||||
|
||||
@@ -256,6 +258,13 @@ cast_clear_if_enabled(true, UserId, ChannelId, MessageId) ->
|
||||
cast_clear_if_enabled(false, _UserId, _ChannelId, _MessageId) ->
|
||||
ok.
|
||||
|
||||
-spec enrolled_clear_notifications_enabled() -> boolean().
|
||||
enrolled_clear_notifications_enabled() ->
|
||||
case persistent_term:get(push_enrolled_clear_notifications_enabled, undefined) of
|
||||
OperatorChoice when is_boolean(OperatorChoice) -> OperatorChoice;
|
||||
_ -> env_boolean(push_enrolled_clear_notifications_enabled, true)
|
||||
end.
|
||||
|
||||
-spec clear_notifications_enabled() -> boolean().
|
||||
clear_notifications_enabled() ->
|
||||
case persistent_term:get(push_clear_notifications_enabled, undefined) of
|
||||
|
||||
@@ -47,6 +47,25 @@ a_clear_is_dropped_only_after_the_retry_budget_is_spent_test() ->
|
||||
meck:unload(push_dispatcher)
|
||||
end.
|
||||
|
||||
an_enrolled_user_gets_clears_while_the_fleet_switch_is_off_test() ->
|
||||
erase_persistent_term(push_noop),
|
||||
erase_persistent_term(push_enrolled_clear_notifications_enabled),
|
||||
persistent_term:put(push_clear_notifications_enabled, false),
|
||||
try
|
||||
?assertEqual(ok, push:clear_channel_notifications(1, 2, 3))
|
||||
after
|
||||
erase_persistent_term(push_clear_notifications_enabled)
|
||||
end.
|
||||
|
||||
the_cohort_switch_can_be_turned_off_on_its_own_test() ->
|
||||
erase_persistent_term(push_noop),
|
||||
persistent_term:put(push_enrolled_clear_notifications_enabled, false),
|
||||
try
|
||||
?assertEqual(ok, push:clear_channel_notifications(1, 2, 3))
|
||||
after
|
||||
erase_persistent_term(push_enrolled_clear_notifications_enabled)
|
||||
end.
|
||||
|
||||
push_owner_key_prefers_first_recipient_test() ->
|
||||
?assertEqual(
|
||||
42,
|
||||
|
||||
Reference in New Issue
Block a user