Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

WIP#410

Draft
ghickman wants to merge 6 commits intomainfrom
slack-backends
Draft

WIP#410
ghickman wants to merge 6 commits intomainfrom
slack-backends

Conversation

@ghickman
Copy link
Copy Markdown
Contributor

Why?
The console backend for emails is really useful when you're working locally. I would like to have that for slack messages too.


We have a very nice DX with our current implementation, in particular but not limited to:

  • the test fixture gives us a great interface to the messages sent
  • construction of a message is done in functions, so it's easy to see the message
  • the channel used can be overridden at call time of functions, making it easy to post to the live API using our testing channel

There are a couple of small frustrations when working with it locally:

  • there's no console view of a message
  • we no-op the send method when running in DEBUG, so posting to the live API requires a little bit more work

The first bullet point caught me out when running through OSI and knowing that a message would be sent but seeing nothing in my console.


This is a test to see how the django-slack package works out.

Some pros from usage:

  • we can still use our functions with channel overrides
  • setting the default backend to the console means we can see the message in the console with testing
  • the testing fixture can be updated to be mostly the same

Some cons:

  • I don't think the templates give us anything over interpolating the messages ourselves
  • the use of extends django_slack in the template dynamically looks up the necessary template and was quite unexpected

@lucyb
Copy link
Copy Markdown
Contributor

lucyb commented Nov 22, 2022

Hmm. There are some very nice aspects to that change, although the templates and the fact that we have to add in another library (for not much benefit) is not great.

As a simple solution to fix the lack of console messages, could we just use the logger inside the post function to send a message to the console? We can then rely on the tests to ensure the message is well formed (and if we can't, then we should fix that anyway)

def post(text, channel="interactive-requests"):
    logger.DEBUG(f"Sending message to {{channel}}")    # Could use a different logging level
    if settings.DEBUG:  # pragma: no cover
        return

    try:

I'm not sure the no-op in DEBUG mode is helpful either, thinking about it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants