diff --git a/apps/duplication/archive_fetch.py b/apps/duplication/archive_fetch.py index e14e7f5bd4..80a8df60ea 100644 --- a/apps/duplication/archive_fetch.py +++ b/apps/duplication/archive_fetch.py @@ -136,11 +136,10 @@ def __strip_version_from_guid(self, guid, version): Checks if guid contains the version for the ingested item and returns the guid without version """ try: - if not version: - return guid - - if guid.endswith(":{}".format(str(version))): + if version and guid.endswith(":{}".format(str(version))): return guid[: -1 * (len(str(version)) + 1)] + else: + return guid except Exception: return guid diff --git a/superdesk/io/feed_parsers/ninjs.py b/superdesk/io/feed_parsers/ninjs.py index 42d14199c1..58511cf25f 100644 --- a/superdesk/io/feed_parsers/ninjs.py +++ b/superdesk/io/feed_parsers/ninjs.py @@ -61,7 +61,9 @@ def can_parse(self, file_path): ninjs = json.load(f) if ninjs.get("uri") or ninjs.get("guid"): return True - except Exception: + except Exception as err: + logger.exception(err) + logger.error("Failed to ingest json file") pass return False diff --git a/superdesk/publish/formatters/ninjs_newsroom_formatter.py b/superdesk/publish/formatters/ninjs_newsroom_formatter.py index 328629a239..82b1b7561d 100644 --- a/superdesk/publish/formatters/ninjs_newsroom_formatter.py +++ b/superdesk/publish/formatters/ninjs_newsroom_formatter.py @@ -39,7 +39,9 @@ def _format_products(self, article): def _transform_to_ninjs(self, article, subscriber, recursive=True): ninjs = super()._transform_to_ninjs(article, subscriber, recursive) - if article.get("ingest_id") and article.get("auto_publish"): + if article.get("ingest_id") and ( + article.get("auto_publish") or (article.get("extra") or {}).get("publish_ingest_id_as_guid") + ): ninjs["guid"] = article.get("ingest_id") if article.get("ingest_version"): ninjs["version"] = article["ingest_version"]