Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
michellebrier committed Feb 28, 2024
1 parent 5a54445 commit 03c97d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ManageEntityParameters,
copy_record,
validate_signer,
get_ddex_apps,
is_ddex_signer,
)
from src.tasks.metadata import immutable_playlist_fields
from src.tasks.task_helpers import generate_slug_and_collision_id
Expand Down Expand Up @@ -279,7 +279,7 @@ def create_playlist(params: ManageEntityParameters):
last_added_to = None

ddex_app = None
if params.signer in get_ddex_apps():
if is_ddex_signer(params.signer):
ddex_app = params.signer

for track in tracks:
Expand Down Expand Up @@ -344,7 +344,7 @@ def dispatch_challenge_playlist_upload(

def validate_update_ddex_playlist(params: ManageEntityParameters, playlist_record):
if playlist_record.ddex_app:
if playlist_record.ddex_app != params.signer or params.signer not in get_ddex_apps():
if playlist_record.ddex_app != params.signer or not is_ddex_signer(params.signer):
raise IndexingValidationError(f"Signer {params.signer} does not have permission to {params.action} DDEX playlist {playlist_record.playlist_id}")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
ManageEntityParameters,
copy_record,
validate_signer,
get_ddex_apps,
is_ddex_signer,
)
from src.tasks.metadata import immutable_track_fields
from src.tasks.task_helpers import generate_slug_and_collision_id
Expand Down Expand Up @@ -463,7 +463,7 @@ def create_track(params: ManageEntityParameters):
is_delete=False,
)

if params.signer in get_ddex_apps():
if is_ddex_signer(params.signer):
track_record.ddex_app = params.signer

update_track_routes_table(
Expand All @@ -489,7 +489,7 @@ def create_track(params: ManageEntityParameters):

def validate_update_ddex_track(params: ManageEntityParameters, track_record):
if track_record.ddex_app:
if track_record.ddex_app != params.signer or params.signer not in get_ddex_apps():
if track_record.ddex_app != params.signer or not is_ddex_signer(params.signer):
raise IndexingValidationError(f"Signer {params.signer} does not have permission to {params.action} DDEX track {track_record.track_id}")


Expand Down
7 changes: 5 additions & 2 deletions packages/discovery-provider/src/tasks/entity_manager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ def get_address_from_signature(signature):
return app_address.lower()


def get_ddex_apps():
def is_ddex_signer(signer):
# TODO read from a table in the db after implementing UI to register a DDEX node
return os.getenv("audius_ddex_apps").split(",")
ddex_apps = os.getenv("audius_ddex_apps")
if ddex_apps:
return signer.removeprefix("0x") in ddex_apps.split(",")
return False

0 comments on commit 03c97d5

Please sign in to comment.