diff --git a/ditto/twitter/fetch/savers.py b/ditto/twitter/fetch/savers.py index d18a19c..51783a4 100644 --- a/ditto/twitter/fetch/savers.py +++ b/ditto/twitter/fetch/savers.py @@ -59,7 +59,6 @@ def save_user(self, user, fetch_time, download_avatar=True): "raw": raw_json, "screen_name": user["screen_name"], "name": user["name"], - "is_private": user["protected"], "is_verified": user["verified"], "profile_image_url_https": user["profile_image_url_https"], } @@ -67,6 +66,9 @@ def save_user(self, user, fetch_time, download_avatar=True): # When ingesting tweets there are lots of fields the 'user' element # doesn't have, compared to the API: + if "protected" in user: + defaults["is_private"] = user["protected"] + if "created_at" in user: defaults["created_at"] = self._api_time_to_datetime(user["created_at"]) diff --git a/ditto/twitter/models.py b/ditto/twitter/models.py index 6a8c96a..8662c32 100644 --- a/ditto/twitter/models.py +++ b/ditto/twitter/models.py @@ -70,7 +70,11 @@ def save(self, *args, **kwargs): # It would be nice to make this more visible, but not sure how to # given we don't have access to a request at this point. - if "success" in result and result["success"] is False: + if ( + type(result) is dict + and "success" in result + and result["success"] is False + ): if "messages" in result: messages = ", ".join(result["messages"]) else: