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

Slack: notification fail in new tray publisher #4118

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
35 changes: 26 additions & 9 deletions openpype/modules/slack/plugins/publish/integrate_slack_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ def _get_filled_message(self, message_templ, instance, review_path=None):
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")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line over-indented for hanging indent

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
Expand Down Expand Up @@ -142,13 +148,17 @@ def _get_filled_message(self, message_templ, instance, review_path=None):

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"""
Expand Down Expand Up @@ -178,10 +188,17 @@ def _python2_call(self, token, channel, message, publish_files):
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
Expand Down