mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-01 04:08:50 -04:00
Revert "Audit api key id when cancelling broadcast via api"
This commit is contained in:
@@ -13,7 +13,7 @@ from app.models import (
|
||||
)
|
||||
|
||||
|
||||
def validate_and_update_broadcast_message_status(broadcast_message, new_status, updating_user=None, api_key_id=None):
|
||||
def validate_and_update_broadcast_message_status(broadcast_message, new_status, updating_user):
|
||||
if new_status not in BroadcastStatusType.ALLOWED_STATUS_TRANSITIONS[broadcast_message.status]:
|
||||
raise InvalidRequest(
|
||||
f'Cannot move broadcast_message {broadcast_message.id} from {broadcast_message.status} to {new_status}',
|
||||
@@ -39,7 +39,6 @@ def validate_and_update_broadcast_message_status(broadcast_message, new_status,
|
||||
if new_status == BroadcastStatusType.CANCELLED:
|
||||
broadcast_message.cancelled_at = datetime.utcnow()
|
||||
broadcast_message.cancelled_by = updating_user
|
||||
broadcast_message.cancelled_by_api_key_id = api_key_id
|
||||
|
||||
current_app.logger.info(
|
||||
f'broadcast_message {broadcast_message.id} moving from {broadcast_message.status} to {new_status}'
|
||||
|
||||
@@ -2322,17 +2322,15 @@ class BroadcastMessage(db.Model):
|
||||
approved_by = db.relationship('User', foreign_keys=[approved_by_id])
|
||||
cancelled_by = db.relationship('User', foreign_keys=[cancelled_by_id])
|
||||
|
||||
created_by_api_key_id = db.Column(UUID(as_uuid=True), db.ForeignKey('api_keys.id'), nullable=True)
|
||||
cancelled_by_api_key_id = db.Column(UUID(as_uuid=True), db.ForeignKey('api_keys.id'), nullable=True)
|
||||
created_by_api_key = db.relationship('ApiKey', foreign_keys=[created_by_api_key_id])
|
||||
cancelled_by_api_key = db.relationship('ApiKey', foreign_keys=[cancelled_by_api_key_id])
|
||||
api_key_id = db.Column(UUID(as_uuid=True), db.ForeignKey('api_keys.id'), nullable=True)
|
||||
api_key = db.relationship('ApiKey')
|
||||
|
||||
reference = db.Column(db.String(255), nullable=True)
|
||||
cap_event = db.Column(db.String(255), nullable=True)
|
||||
|
||||
stubbed = db.Column(db.Boolean, nullable=False)
|
||||
|
||||
CheckConstraint("created_by_id is not null or created_by_api_key_id is not null")
|
||||
CheckConstraint("created_by_id is not null or api_key_id is not null")
|
||||
|
||||
@property
|
||||
def personalisation(self):
|
||||
|
||||
@@ -81,7 +81,7 @@ def create_broadcast():
|
||||
'simple_polygons': simple_polygons.as_coordinate_pairs_lat_long,
|
||||
},
|
||||
status=BroadcastStatusType.PENDING_APPROVAL,
|
||||
created_by_api_key_id=api_user.id,
|
||||
api_key_id=api_user.id,
|
||||
stubbed=authenticated_service.restricted
|
||||
# The client may pass in broadcast_json['expires'] but it’s
|
||||
# simpler for now to ignore it and have the rules around expiry
|
||||
@@ -111,7 +111,7 @@ def _cancel_or_reject_broadcast(references_to_original_broadcast, service_id):
|
||||
validate_and_update_broadcast_message_status(
|
||||
broadcast_message,
|
||||
new_status,
|
||||
api_key_id=api_user.id
|
||||
updating_user=None
|
||||
)
|
||||
return broadcast_message
|
||||
|
||||
|
||||
Reference in New Issue
Block a user