Feature: Slack gig notifications#197
Conversation
This is for readability, and to prepare for a similar method to send Slack messages
|
For the record: I initially tried using the official Slack Python library, |
|
Ultimately, how will this work? Every band will have a slack channel to subscribe to? There's only one gig-o slack channel? I'm not enough of a slack user to know the best way. If you want to talk to the other folks who have requested this, let me know - they likely have opinions. |
|
The goal is to put messages into each band's own Slack group, and let each band control the room into which announcements are posted. The default will be As for enrollment, the flow I have in mind is this:
Possible later enhancements:
|
* Send just one message per band (instead of one per member) * Link to the general Gig Info page, not to a specific member’s URL * Include more gig details: confirmation status, date, time(s)
|
Updated screenshot showing improved message format added to description |
|
Got it - that's cool! |
AppEngine only provides Jinja2 2.6, which does not include several useful new built-in filters, including `urlencode`
Until a band is saved, we don’t have an ID to use for callbacks, so it doesn’t make sense to show the button on the New form
|
@aaronoppenheimer This is almost ready! One question for you: we need to stick a secret key into the app, which represents how the app authenticates itself to Slack. The key should not be in the repo because it is a security token. How would you like to handle this? Should we essentially copy the mechanism you use for setting the CryptoKey? This key is only settable by the site admin, and should not ever (or extremely rarely) change, so perhaps UI is not required. What are your thoughts? |
|
@bklang Any reason not to just use the same key? |
* Separate announcements functionality out from toenail to go announcements * Move Slack-specific functionality to goslack
We can't. The authentication token is provided by Slack as part of the registration process. Gig-O-Matic will have to register itself as a Slack App, for which the token will be generated by Slack. Currently, I'm using a copy of the app registered to one of my own Slack accounts, but obviously for production we can re-register it to an account for Gig-O (or leave it under my account if you prefer - I recall you saying you're not a Slack user). |
|
Oh, I get it. Well, we could use the slack API token as the crypto key, which is just a random string now anyway. Or you could just add another input box on the admin crypto page and store it separately. |
|
That also won't work :( Slack actually provides two pieces of information that we have to hang on to: a Client ID and a Client Secret. |
|
Ha, OK, I give up. I'd just add a couple of fields to the crypto admin page and handle it all in there. It's only going to be touched by me, once, so it doesn't have to be pretty! |
a80921d to
eac1278
Compare
Use this page to manage other app secrets
|
@aaronoppenheimer Alright, this is ready to go! I made the changes we discussed: renamed the "Crypto Admin" page to "Secrets Admin" and added the two fields for Slack Client ID and Secret: Would you do code review and let me know if you would like to see any changes? It's also worth noting that a fair amount of code changed in |
|
Hi Brian, Works and very cool! A couple of things: There's some alignment problem I see on the edit band page: Also, get an error if there is no admin defined for a band (there's some code to handle this in there but doesn't seem to be working):
|
The form was relying on the_band to have real data, which it doesn’t yet
Addresses the reported formatting problem
|
Also, should add a way to turn off slack notifications for a band, too. |
|
I've pushed a fix for the alignment issue. I've added a TODO for a way to dis-enroll the band from Slack, which will stop notifications. Looking into the exception that you hit, this one is a little trickier. The code is trying to localize the date string. The assumption is that the first band admin is in the same locale as the rest of the band's members. So we try to find the first admin, and then format the date to his/her locale. If an admin can't be found, then we try to take the first invited member and format it to his/her locale. Unfortunately, I've found a few ways this can fail:
I'm still working out how to fix the issue. If anything obvious jumps out at you, suggestions welcome! |
|
Hi Ben, Well, a couple of things. For one thing, a band might not have any invited members - a member is only "invited" when they're sent an invitation. If they don't join that way (like, they go to the home page and just register) they're not marked "invited" and even if they were invited through the email system, "is_invited" is set to false once they confirm. So, you could just use any confirmed member - use get_confirmed_assocs_of_band_key instead. There's some chance that you'll pick someone who has language set for 'english' though everyone else in their band uses 'Italian' - so the slack message will show the date in the English format. Definitely a corner case. We could add a default language for band announcements (I guess that would be for the RSS stream, too) if it turns out to be a problem for anyone. |
|
Putting the preference on the Band probably makes the most sense, but I'm not sure how to handle a migration of existing data (to set a default locale). I think I'd prefer to address per-Band-locales in a separate PR. Alright with you if I make the logic work as-is? |
52ecd1e to
4fd7760
Compare
|
Yes about the band language preference - I'm sure it doesn't really matter and I'd put it on the bottom of the list! |
|
If I cancel out of the slack authorization process I get an error back on the gig-o...
|
|
@aaronoppenheimer Button added to disconnect from Slack: I think that's all the concerns addressed? |
|
Ah, just saw your comment about canceling out of the Slack signup process. It's easy enough to detect (that's where the error message you saw came from), but what's the convention for displaying error messages? I will improve the text of the message, but can you point to an example in the app of how you might display it? |
|
Hi Ben - I'm not sure it's an error. If I go to connect Slack but then cancel out, I think it's fine to just return to the edit page as if I hadn't pressed the connect button at all. Y'know? And - if I make a bunch of changes to the page and then go to the slack connection path, I'll lose all of the changes I made - we lose the form contents and when I get back it's all reset. I wonder if there's a way to manage that? Maybe the "connect slack" button should be on the band info page. There's the link to the calendar feed - maybe band admins see the "connect to slack" option below that. Regular members could just see a message there like "the band is connected to Slack" once the connection is made. |



WIP
TODO: