Celery Support
django_slack_tools.slack_messages.tasks
Celery utils.
cleanup_old_messages(*, base_ts=None, threshold_seconds=7 * 24 * 60 * 60)
Delete old messages created before given threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
threshold_seconds |
int | None
|
Threshold seconds. Defaults to 7 days. |
7 * 24 * 60 * 60
|
base_ts |
str | None
|
Base timestamp to calculate the threshold, in ISO format. If falsy, current timestamp will be used. |
None
|
Returns:
Type | Description |
---|---|
int
|
Number of deleted messages. |
Source code in django_slack_tools/slack_messages/tasks.py
slack_message(body, *, channel, header=None, raise_exception=False, get_permalink=False)
Celery task wrapper for message.slack_message
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body |
str | dict[str, Any]
|
Message content, simple message or full request body. |
required |
channel |
str
|
Channel to send message. |
required |
header |
dict[str, Any] | None
|
Slack message control header. |
None
|
raise_exception |
bool
|
Whether to re-raise caught exception while sending messages. |
False
|
get_permalink |
bool
|
Try to get the message permalink via extraneous Slack API calls. |
False
|
Returns:
Type | Description |
---|---|
int | None
|
ID of sent message. |
Source code in django_slack_tools/slack_messages/tasks.py
slack_message_via_policy(policy, *, header=None, raise_exception=False, lazy=False, get_permalink=False, context=None)
Celery task wrapper for message.slack_message_via_policy
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
policy |
str
|
Messaging policy code. |
required |
header |
dict[str, Any] | None
|
Slack message control header. |
None
|
raise_exception |
bool
|
Whether to re-raise caught exception while sending messages. |
False
|
lazy |
bool
|
Decide whether try to create policy with disabled, if not exists. |
False
|
get_permalink |
bool
|
Try to get the message permalink via extraneous Slack API calls. |
False
|
context |
dict[str, Any] | None
|
Context variables for message rendering. |
None
|
Returns:
Type | Description |
---|---|
int
|
Number of sent messages. |