mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #4118 from pypeclub/bugfix/OP-4196_Slack-notification-fail-in-New-Tray-Publisher
Slack: notification fail in new tray publisher
This commit is contained in:
commit
ef313d85a4
2 changed files with 29 additions and 12 deletions
|
|
@ -18,15 +18,15 @@ class CollectSlackFamilies(pyblish.api.InstancePlugin):
|
|||
profiles = None
|
||||
|
||||
def process(self, instance):
|
||||
task_name = legacy_io.Session.get("AVALON_TASK")
|
||||
task_data = instance.data["anatomyData"].get("task", {})
|
||||
family = self.main_family_from_instance(instance)
|
||||
key_values = {
|
||||
"families": family,
|
||||
"tasks": task_name,
|
||||
"tasks": task_data.get("name"),
|
||||
"task_types": task_data.get("type"),
|
||||
"hosts": instance.data["anatomyData"]["app"],
|
||||
"subsets": instance.data["subset"]
|
||||
}
|
||||
|
||||
profile = filter_profiles(self.profiles, key_values,
|
||||
logger=self.log)
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,13 @@ class IntegrateSlackAPI(pyblish.api.InstancePlugin):
|
|||
if review_path:
|
||||
fill_pairs.append(("review_filepath", review_path))
|
||||
|
||||
task_data = fill_data.get("task")
|
||||
task_data = (
|
||||
copy.deepcopy(instance.data.get("anatomyData", {})).get("task")
|
||||
or fill_data.get("task")
|
||||
)
|
||||
if not isinstance(task_data, dict):
|
||||
# fallback for legacy - if task_data is only task name
|
||||
task_data["name"] = task_data
|
||||
if task_data:
|
||||
if (
|
||||
"{task}" in message_templ
|
||||
|
|
@ -142,13 +148,17 @@ class IntegrateSlackAPI(pyblish.api.InstancePlugin):
|
|||
|
||||
def _get_thumbnail_path(self, instance):
|
||||
"""Returns abs url for thumbnail if present in instance repres"""
|
||||
published_path = None
|
||||
thumbnail_path = None
|
||||
for repre in instance.data.get("representations", []):
|
||||
if repre.get('thumbnail') or "thumbnail" in repre.get('tags', []):
|
||||
if os.path.exists(repre["published_path"]):
|
||||
published_path = repre["published_path"]
|
||||
repre_thumbnail_path = (
|
||||
repre.get("published_path") or
|
||||
os.path.join(repre["stagingDir"], repre["files"])
|
||||
)
|
||||
if os.path.exists(repre_thumbnail_path):
|
||||
thumbnail_path = repre_thumbnail_path
|
||||
break
|
||||
return published_path
|
||||
return thumbnail_path
|
||||
|
||||
def _get_review_path(self, instance):
|
||||
"""Returns abs url for review if present in instance repres"""
|
||||
|
|
@ -178,10 +188,17 @@ class IntegrateSlackAPI(pyblish.api.InstancePlugin):
|
|||
channel=channel,
|
||||
title=os.path.basename(p_file)
|
||||
)
|
||||
attachment_str += "\n<{}|{}>".format(
|
||||
response["file"]["permalink"],
|
||||
os.path.basename(p_file))
|
||||
file_ids.append(response["file"]["id"])
|
||||
if response.get("error"):
|
||||
error_str = self._enrich_error(
|
||||
str(response.get("error")),
|
||||
channel)
|
||||
self.log.warning(
|
||||
"Error happened: {}".format(error_str))
|
||||
else:
|
||||
attachment_str += "\n<{}|{}>".format(
|
||||
response["file"]["permalink"],
|
||||
os.path.basename(p_file))
|
||||
file_ids.append(response["file"]["id"])
|
||||
|
||||
if publish_files:
|
||||
message += attachment_str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue