response is a dict just now

I don't know what I was thinking.
Add some type checking while I am at it.
This commit is contained in:
tcely 2024-12-21 07:53:23 -05:00 committed by GitHub
parent 54f2663f82
commit cf951a820a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,6 @@
import os
import json
from pathlib import Path
from django.conf import settings
from copy import copy
@ -85,16 +84,14 @@ def _subscriber_only(msg='', response=None):
return True
else:
# ignore msg entirely
try:
data = json.loads(str(response))
except (TypeError, ValueError, AttributeError):
return False
if not isinstance(response, dict):
raise TypeError(f'response must be a dict, got "{type(response)}" instead')
if 'availability' not in data.keys():
if 'availability' not in response.keys():
return False
# check for the specific expected value
return 'subscriber_only' == data.get('availability')
return 'subscriber_only' == response.get('availability')
return False