Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPCN-27] Improvements to NinJS ingests & publishing #2482

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions apps/duplication/archive_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion superdesk/io/feed_parsers/ninjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion superdesk/publish/formatters/ninjs_newsroom_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Loading