mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Added dynamic message to Slack notification
Artist can now add additional message, specific per instance and publish, if they are using Publisher.
This commit is contained in:
parent
e377b03e78
commit
ae709afaaf
3 changed files with 34 additions and 6 deletions
|
|
@ -1,10 +1,12 @@
|
|||
import pyblish.api
|
||||
|
||||
from openpype.lib.profiles_filtering import filter_profiles
|
||||
from openpype.pipeline import legacy_io
|
||||
from openpype.lib import attribute_definitions
|
||||
from openpype.pipeline import OpenPypePyblishPluginMixin
|
||||
|
||||
|
||||
class CollectSlackFamilies(pyblish.api.InstancePlugin):
|
||||
class CollectSlackFamilies(pyblish.api.InstancePlugin,
|
||||
OpenPypePyblishPluginMixin):
|
||||
"""Collect family for Slack notification
|
||||
|
||||
Expects configured profile in
|
||||
|
|
@ -17,6 +19,18 @@ class CollectSlackFamilies(pyblish.api.InstancePlugin):
|
|||
|
||||
profiles = None
|
||||
|
||||
@classmethod
|
||||
def get_attribute_defs(cls):
|
||||
return [
|
||||
attribute_definitions.TextDef(
|
||||
# Key under which it will be stored
|
||||
"additional_message",
|
||||
# Use plugin label as label for attribute
|
||||
label="Additional Slack message",
|
||||
placeholder="<Only if Slack is configured>"
|
||||
)
|
||||
]
|
||||
|
||||
def process(self, instance):
|
||||
task_data = instance.data["anatomyData"].get("task", {})
|
||||
family = self.main_family_from_instance(instance)
|
||||
|
|
@ -55,6 +69,11 @@ class CollectSlackFamilies(pyblish.api.InstancePlugin):
|
|||
["token"])
|
||||
instance.data["slack_token"] = slack_token
|
||||
|
||||
attribute_values = self.get_attr_values_from_data(instance.data)
|
||||
additional_message = attribute_values.get("additional_message")
|
||||
if additional_message:
|
||||
instance.data["slack_additional_message"] = additional_message
|
||||
|
||||
def main_family_from_instance(self, instance): # TODO yank from integrate
|
||||
"""Returns main family of entered instance."""
|
||||
family = instance.data.get("family")
|
||||
|
|
|
|||
|
|
@ -31,11 +31,14 @@ class IntegrateSlackAPI(pyblish.api.InstancePlugin):
|
|||
review_path = self._get_review_path(instance)
|
||||
|
||||
publish_files = set()
|
||||
message = ''
|
||||
additional_message = instance.data.get("slack_additional_message")
|
||||
if additional_message:
|
||||
message = "{} \n".format(additional_message)
|
||||
for message_profile in instance.data["slack_channel_message_profiles"]:
|
||||
message = self._get_filled_message(message_profile["message"],
|
||||
instance,
|
||||
review_path)
|
||||
self.log.debug("message:: {}".format(message))
|
||||
message += self._get_filled_message(message_profile["message"],
|
||||
instance,
|
||||
review_path)
|
||||
if not message:
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,12 @@ Few keys also have Capitalized and UPPERCASE format. Values will be modified acc
|
|||
Here you can find review {review_filepath}
|
||||
```
|
||||
|
||||
##### Dynamic message for artists
|
||||
If artists uses host with implemented Publisher (new UI for publishing, implemented in Tray Publisher, Adobe products etc), it is possible for
|
||||
them to add additional message (notification for specific users for example, artists must provide proper user id with '@').
|
||||
Additional message will be sent only if at least one profile, eg. one target channel is configured.
|
||||
All available template keys (see higher) could be used here as a placeholder too.
|
||||
|
||||
#### Message retention
|
||||
Currently no purging of old messages is implemented in Openpype. Admins of Slack should set their own retention of messages and files per channel.
|
||||
(see https://slack.com/help/articles/203457187-Customize-message-and-file-retention-policies)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue