Clear user cache when broadcast service settings form is submitted

When the broadcast service settings form is submitted it now removes all
permissions for users in notifications-api. This means it should be
clearing the user cache.
This commit is contained in:
Katie Smith
2021-07-13 17:06:35 +01:00
parent aefbe7709b
commit 5b52b6f9bf
4 changed files with 29 additions and 4 deletions

View File

@@ -396,11 +396,14 @@ def service_confirm_broadcast_account_type(service_id, account_type):
abort(404)
if form.validate_on_submit():
cached_service_user_ids = [user.id for user in current_service.active_users]
service_api_client.set_service_broadcast_settings(
current_service.id,
service_mode=form.account_type.service_mode,
broadcast_channel=form.account_type.broadcast_channel,
provider_restriction=form.account_type.provider_restriction
provider_restriction=form.account_type.provider_restriction,
cached_service_user_ids=cached_service_user_ids
)
create_broadcast_account_type_change_event(
service_id=current_service.id,

View File

@@ -618,13 +618,16 @@ class ServiceAPIClient(NotifyAdminAPIClient):
@cache.delete('service-{service_id}')
def set_service_broadcast_settings(
self, service_id, service_mode, broadcast_channel, provider_restriction
self, service_id, service_mode, broadcast_channel, provider_restriction, cached_service_user_ids
):
"""
service_mode is one of "training" or "live"
broadcast channel is one of "test" or "severe"
broadcast channel is one of "operator", "test", "severe", "government"
provider_restriction is one of "all", "three", "o2", "vodafone", "ee"
"""
if cached_service_user_ids:
redis_client.delete(*map('user-{}'.format, cached_service_user_ids))
data = {
"service_mode": service_mode,
"broadcast_channel": broadcast_channel,