Skip to content

Commit

Permalink
[SDESK-6829] fix: RoutingRule publishes item twice on update (#1761)
Browse files Browse the repository at this point in the history
* [SDESK-6829] fix: RoutingRule publishes item twice on update

* fix typo
  • Loading branch information
MarkLark86 authored Feb 16, 2023
1 parent 4476568 commit cdaa1a4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server/planning/io/ingest_rule_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,19 @@ def apply_rule(self, rule: Dict[str, Any], ingest_item: Dict[str, Any], routing_
if updates is not None:
ingest_item.update(updates)

if attributes.get("autopost", False):
if attributes.get("autopost", False) and (updates is None or not self._is_original_posted(ingest_item)):
# Only autopost if:
# * The original has not been posted yet
# * Or there are no updates applied (from assigning Calendar/Agenda to the item)
# because updating the Calendar/Agenda will automatically re-post the item for us
self.process_autopost(ingest_item)

def _is_original_posted(self, ingest_item: Dict[str, Any]):
service = get_resource_service("events" if ingest_item[ITEM_TYPE] == CONTENT_TYPE.EVENT else "planning")
original = service.find_one(req=None, _id=ingest_item.get(config.ID_FIELD))

return original.get("pubstatus") in [POST_STATE.USABLE, POST_STATE.CANCELLED]

def add_event_calendars(self, ingest_item: Dict[str, Any], attributes: Dict[str, Any]) -> Optional[Dict[str, Any]]:
"""Add Event Calendars from Routing Rule Action onto the ingested item"""

Expand Down

0 comments on commit cdaa1a4

Please sign in to comment.