Skip to content

Commit

Permalink
api.schedule.ProposalC3VOCPublishingWebhook: better logic on when (no…
Browse files Browse the repository at this point in the history
…t) to overwrite values
  • Loading branch information
Kunsi committed Aug 31, 2024
1 parent bff1726 commit c5f8aea
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions apps/api/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,36 @@ def post(self):

proposal = Proposal.query.get_or_404(proposal_id)

if payload["voctoweb"]["enabled"] and payload["voctoweb"]["frontend_url"]:
proposal.c3voc_url = payload["voctoweb"]["frontend_url"]
proposal.video_recording_lost = False
else:
# This allows c3voc to notify us if videos got depublished
# as well. We do not explicitely set 'video_recording_lost'
# here because the video might only need fixing audio or
# such.
proposal.c3voc_url = ""

if payload["youtube"]["enabled"] and payload["youtube"]["urls"]:
# c3voc will send us a list, even though we only have one
# video.
proposal.youtube_url = payload["youtube"]["urls"][0]
proposal.video_recording_lost = False
else:
proposal.youtube_url = ""
if payload["voctoweb"]["enabled"]:
if payload["voctoweb"]["frontend_url"]:
proposal.c3voc_url = payload["voctoweb"]["frontend_url"]
proposal.video_recording_lost = False
else:
# This allows c3voc to notify us if videos got depublished
# as well. We do not explicitely set 'video_recording_lost'
# here because the video might only need fixing audio or
# such.
proposal.c3voc_url = ""

if payload["youtube"]["enabled"]:
if payload["youtube"]["urls"]:
# Please do not overwrite existing youtube urls
if not proposal.youtube_url:
# c3voc will send us a list, even though we only have one
# video.
proposal.youtube_url = payload["youtube"]["urls"][0]
proposal.video_recording_lost = False
elif proposal.youtube_url not in payload["youtube"]["urls"]:
# c3voc sent us some urls, but none of them are matching
# the url we have in our database.
app.logger.warning(
f"C3VOC webhook sent youtube urls {payload['youtube']['urls']!r}, "
f"but we already have {proposal.youtube_url}. NOT "
"overwriting!"
)
else:
# see comment at c3voc_url above
proposal.youtube_url = ""

db.session.add(proposal)
db.session.commit()
Expand Down

0 comments on commit c5f8aea

Please sign in to comment.