Merge remote-tracking branch 'origin/master' into accounts

This commit is contained in:
Karol Wypchlo 2021-03-03 14:38:49 +01:00
commit c2f4254249
2 changed files with 6 additions and 4 deletions

View File

@ -36,10 +36,12 @@ async def block_skylinks_from_airtable():
return print(message) or await send_msg(client, message, force_notify=False) return print(message) or await send_msg(client, message, force_notify=False)
data = response.json() data = response.json()
skylinks = skylinks + [entry["fields"].get(AIRTABLE_FIELD, "") for entry in data["records"]]
if len(skylinks) == 0: if len(data["records"]) == 0:
return print("Airtable returned 0 skylinks - make sure your configuration is correct") return print("Airtable returned 0 records - make sure your configuration is correct")
skylinks = skylinks + [entry["fields"].get(AIRTABLE_FIELD, "") for entry in data["records"]]
skylinks = [skylink for skylink in skylinks if skylink] # filter empty skylinks, most likely empty rows
offset = data.get("offset") offset = data.get("offset")

View File

@ -97,7 +97,7 @@ async def send_msg(client, msg, force_notify=False, file=None):
# Add the portal name. # Add the portal name.
msg = "**{}**: {}".format(portal_name, msg) msg = "**{}**: {}".format(portal_name, msg)
if isinstance(file, str): if file and isinstance(file, str):
is_json = is_json_string(file) is_json = is_json_string(file)
content_type = "application/json" if is_json else "text/plain" content_type = "application/json" if is_json else "text/plain"
ext = "json" if is_json else "txt" ext = "json" if is_json else "txt"