Discord Integration Option
Review Request #11201 — Created Sept. 24, 2020 and submitted
Added a Discord Integration option.
This allows Review Board to have an option of notifying Discord channels on
any Review Request changes. This commit also includes a refactoring of the
notify() function in SlackIntegration.
Added unit tests in discord/tests.py and they pass in RB3 virtual
environment. RB4 has two exceptions (please see below).Tested it manually in reviewboard 3.0.x and 4.0.x.
Issues that still need to be addressed:
-
Add assets (e.g. logos, trophies, etc.) at this location:
https://static.reviewboard.org/integration-assets/discord -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here in RB4 -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
Summary | ID | Author |
---|---|---|
b1cff2eb4fe7f953704b96c252b7b96564b31464 | HailanXyouknow |
Description | From | Last Updated |
---|---|---|
E261 at least two spaces before inline comment |
reviewbot | |
E262 inline comment should start with '# ' |
reviewbot | |
E261 at least two spaces before inline comment |
reviewbot | |
E262 inline comment should start with '# ' |
reviewbot | |
Please remove. |
MarcusBoay | |
TODO comment? |
MarcusBoay | |
Should this be Discord instead? |
MarcusBoay | |
Should this be Discord instead? |
MarcusBoay | |
Should this be Discord instead? |
MarcusBoay | |
Should this be Discord instead? |
MarcusBoay | |
It's more of a nitpick but 'mattemost' -> 'discord' |
MarcusBoay | |
Let's use double quotes for the quotation marks inside the string. |
david | |
Please add a blank line between these two. |
david | |
Maybe move the contents of this method back into the integration class? I don't see a good reason to have … |
david | |
Please use single quotes for these. |
david | |
Can we use a named logger here? At the top level of the file, add: logger = logging.getLogger(__name__) This can … |
david | |
There's an extra blank line here that can be removed. |
david | |
Please add a module docstring to the top of this file. |
david | |
Add a blank line between these two. |
david | |
Leftover debug output? |
david | |
This line isn't necessary. |
david | |
E302 expected 2 blank lines, found 1 |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
Instead of using the continuation character here, can we wrap this in parens? |
david | |
As per the coding style guide, I believe these imports should be moved down to a new group as they … |
keanweng | |
Missing period here. |
keanweng | |
Should be in alphabetical order. |
keanweng | |
These imports should be moved down a group too. |
keanweng | |
Let's switch the use of single- and double-quotes here: help_text=_('Your unique Discord webhook URL. This can be found at ' … |
david | |
These two lines should be swapped (alphabetical order). |
chipx86 | |
I think that lines 11 and 12 should be swapped so that they follow alphabetical order. |
jblazusi | |
Two blank lines between imports and other code. |
chipx86 | |
I noticed that other review board files have 2 lines below the import statements. So I think that you should … |
jblazusi | |
This should use ugettext_lazy, like the form does. |
chipx86 | |
Mind putting this in alphabetical order? Helps keep things organized as new settings are added. |
chipx86 | |
You can bump this to a modern date and time. |
chipx86 | |
This appears to be in the wrong spot. Should be further down, under event_name, and have , optional. |
chipx86 | |
Should have , optional |
chipx86 | |
Can you pass these as keyword arguments? Helps avoid issues as parameters get added, and keeps code readable. |
chipx86 | |
No need for the blank line here. We can convey this as one "paragraph", where we're building the initial state … |
chipx86 | |
Can you use '%s/slack' % config.... form? |
chipx86 | |
Can you set this to alphabetical order? |
chipx86 | |
If you use logger.exception, you won't need exc_info=True. |
chipx86 | |
Doesn't look like this function is doing that, at least not directly. Maybe state what it wraps, so it's clear … |
chipx86 | |
We don't need docstrings for setUp or tearDown. Sort of an exception to a rule. |
chipx86 | |
You can pass id=12321 to create_review_request() (in fact, it's important to do that — old code may not though). |
chipx86 | |
Same here with id=. |
chipx86 | |
No need to call this, since we already created it above. |
chipx86 | |
This will need a docstring. |
chipx86 | |
This can be a single statement. |
chipx86 | |
These all list , optional, but the arguments are all required in the method signature. |
chipx86 | |
Can you pass all these as keyword arguments? |
chipx86 | |
E201 whitespace after '{' |
reviewbot | |
E202 whitespace before '}' |
reviewbot | |
I have to add .encode('UTF-8) at the end of this line to get it to work for some reason. Running … |
ruonanjia | |
Can you say "integration on Discord", so it's clear where they need to add this? |
chipx86 | |
This has two spellings of "Webhook": "Webhook" and "WebHook". Not your fault — we're inconsistent in places as well. I … |
chipx86 | |
"that that" -> "that" |
chipx86 | |
No space after the comma. |
chipx86 | |
lowercase: "utf-8". |
chipx86 | |
To check, is there a reason we use this User-Agent? If so, we should document this. If not, we shouldn't … |
chipx86 | |
Let's use "webhook". |
chipx86 | |
This is indented too far. |
chipx86 | |
Should be "dict". |
chipx86 | |
Since there's only one, how about just attachment? |
chipx86 | |
It's best to avoid one-line dictionaries with multiple keys, as it becomes harder to add to. Let's do: return { … |
chipx86 |
- Change Summary:
-
Using Slack's format for Discord webhook messages. It looks cleaner
this way - we don't need to do weird things like translating hex
color code to decimal numbers - Description:
-
~ Looks like this right now.
~ Still trying to figure out how to pass in all the relevant fields. ~ ~ Admins can add a Discord Integration to their Review Board. After
~ setting it up, it will alert them on the changes of Review Request ~ in the specified Discord Server. - Commits:
-
Summary ID Author ef1955ee8bc031dd3a8ef98cb42ff730e860066c HailanXyouknow b2f02558f931c87ef0644c8048373f161219fe4b HailanXyouknow - Diff:
-
Revision 2 (+662 -38)
- Summary:
-
[WIP] Discord Integration OptionDiscord Integration Option
- Description:
-
Admins can add a Discord Integration to their Review Board. After
setting it up, it will alert them on the changes of Review Request in the specified Discord Server. + + Also refactored Slack Integration (with the help of Christian).
- Testing Done:
-
+ I've run the unit tests in tests.py. Please also see my demo.
+ + There are still things that need to be figured out:
+ + -
Adding assets at this location:
https://static.reviewboard.org/integration-assets/discord
+ -
Delete lines 67 and 68 in discord/integrations.py after Review Request #11211
is pushed
+ -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
-
- Commits:
-
Summary ID Author b2f02558f931c87ef0644c8048373f161219fe4b HailanXyouknow 1907b9af3032c7a94a5fabe4f9913e7853bfd235 HailanXyouknow - Diff:
-
Revision 3 (+3958 -38)
Checks run (2 succeeded)
- Description:
-
Admins can add a Discord Integration to their Review Board. After
~ setting it up, it will alert them on the changes of Review Request ~ in the specified Discord Server. ~ setting it up, it will alert them on the changes of Review Requests ~ in a Discord channel. Also refactored Slack Integration (with the help of Christian).
- Testing Done:
-
~ I've run the unit tests in tests.py. Please also see my demo.
~ I've run the unit tests in tests.py. Please also see my demo (in RB4.0.X).
+ I've also tested it in RB3.0.X. There are still things that need to be figured out:
-
Adding assets at this location:
https://static.reviewboard.org/integration-assets/discord
-
Delete lines 67 and 68 in discord/integrations.py after Review Request #11211
is pushed
~ -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
~ -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
UPDATE: the two unit tests mentioned above passes when running in the
reviewboard-3 virtual environment with the script at
.../reviewboard-3.0/bin/rbext
-
- Change Summary:
-
I realized that the Integrations in extensions.py are in alphabetical order,
so this update is made to address this. - Description:
-
~ Admins can add a Discord Integration to their Review Board. After
~ setting it up, it will alert them on the changes of Review Requests ~ in a Discord channel. ~ ~ Added a Discord Integration option.
~ This allows Review Board to have an option of notifying Discord channels on ~ any Review Request changes. This commit also includes a refactoring of the ~ notify() function in SlackIntegration. - Also refactored Slack Integration (with the help of Christian).
- Testing Done:
-
~ I've run the unit tests in tests.py. Please also see my demo (in RB4.0.X).
~ I've also tested it in RB3.0.X. ~ Added unit tests in discord/tests.py and they pass in RB3. RB4 has two
~ exceptions (please see below). + Please also see my RB4 Discrod Integration demo at + https://www.youtube.com/watch?v=vKY1b60UkmA&ab_channel=ReviewBoard + I've also tested it manually in RB3. ~ There are still things that need to be figured out:
~ Issues that still need to be addressed:
~ -
Adding assets at this location:
https://static.reviewboard.org/integration-assets/discord
~ -
Delete lines 67 and 68 in discord/integrations.py after Review Request #11211
is pushed
~ -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
UPDATE: the two unit tests mentioned above passes when running in the
reviewboard-3 virtual environment with the script at
.../reviewboard-3.0/bin/rbext
~ -
Add assets (e.g. logos, trophies, etc.) at this location:
https://static.reviewboard.org/integration-assets/discord
~ -
Delete lines 67 and 68 in discord/integrations.py after Review Request #11211
is pushed
~ -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here in RB4 -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
-
- Commits:
-
Summary ID Author 1907b9af3032c7a94a5fabe4f9913e7853bfd235 HailanXyouknow cda9a1569a2711fe3e5a1585ca6699a6e2d002e3 HailanXyouknow - Diff:
-
Revision 4 (+3958 -38)
- Added Files:
Checks run (2 succeeded)
- Change Summary:
-
Address feedbacks
- Commits:
-
Summary ID Author cda9a1569a2711fe3e5a1585ca6699a6e2d002e3 HailanXyouknow cea446b49eba25b641cfb5fcfea406395105fa2d HailanXyouknow - Diff:
-
Revision 5 (+3960 -38)
Checks run (2 succeeded)
-
Looking pretty solid. Just some style-related comments.
-
-
-
Maybe move the contents of this method back into the integration class? I don't see a good reason to have a separate top-level function here.
-
-
Can we use a named logger here? At the top level of the file, add:
logger = logging.getLogger(__name__)
This can then be
logger.debug(...)
-
-
-
-
-
- Change Summary:
-
Addressed David's feedback. Tested DiscordIntegration manually and reran the unit tests.
- Commits:
-
Summary ID Author cea446b49eba25b641cfb5fcfea406395105fa2d HailanXyouknow 12104735761a778bc8d4283cd0d8ef263bd07210 HailanXyouknow - Diff:
-
Revision 6 (+3844 -38)
Checks run (1 failed, 1 succeeded)
flake8
- Change Summary:
-
Fix indentation problems
- Commits:
-
Summary ID Author 12104735761a778bc8d4283cd0d8ef263bd07210 HailanXyouknow 7c05b3f23fa8380ca2a738e91f1870ce696d473a HailanXyouknow - Diff:
-
Revision 7 (+3844 -38)
Checks run (2 succeeded)
- Change Summary:
-
Long string now in parentheses
- Commits:
-
Summary ID Author 7c05b3f23fa8380ca2a738e91f1870ce696d473a HailanXyouknow 927894ccbc9e1e0468fdf5fdfc602f96db270bce HailanXyouknow - Diff:
-
Revision 8 (+3836 -38)
Checks run (2 succeeded)
- Change Summary:
-
Removed a line after Slack Colour bug Review Request is pushed.
- Commits:
-
Summary ID Author 927894ccbc9e1e0468fdf5fdfc602f96db270bce HailanXyouknow 7257c22d0cfb79fee60545cb5021bb7345489de5 HailanXyouknow - Diff:
-
Revision 9 (+3830 -38)
Checks run (2 succeeded)
- Testing Done:
-
Added unit tests in discord/tests.py and they pass in RB3. RB4 has two
exceptions (please see below). ~ Please also see my RB4 Discrod Integration demo at ~ Please also see my RB4 Discord Integration demo at https://www.youtube.com/watch?v=vKY1b60UkmA&ab_channel=ReviewBoard I've also tested it manually in RB3. Issues that still need to be addressed:
-
Add assets (e.g. logos, trophies, etc.) at this location:
https://static.reviewboard.org/integration-assets/discord
~ -
Delete lines 67 and 68 in discord/integrations.py after Review Request #11211
is pushed
~ -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here in RB4 -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
- -
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here in RB4 -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
-
- Commits:
-
Summary ID Author 7257c22d0cfb79fee60545cb5021bb7345489de5 HailanXyouknow c3706347c29c9d828cd0b542a5d03b63849533d9 HailanXyouknow - Diff:
-
Revision 10 (+3830 -38)
Checks run (2 succeeded)
- Change Summary:
-
Address feedback
- Commits:
-
Summary ID Author c3706347c29c9d828cd0b542a5d03b63849533d9 HailanXyouknow 1c92b2dda999f80ff90c8b40bfcdc57c028796de HailanXyouknow - Diff:
-
Revision 11 (+3830 -38)
Checks run (2 succeeded)
-
This looks great! Most of my comments are just small style nits for code/docs.
-
-
-
-
-
-
This appears to be in the wrong spot. Should be further down, under
event_name
, and have, optional
. -
-
Can you pass these as keyword arguments? Helps avoid issues as parameters get added, and keeps code readable.
-
No need for the blank line here. We can convey this as one "paragraph", where we're building the initial state of the payload.
-
-
-
-
Doesn't look like this function is doing that, at least not directly. Maybe state what it wraps, so it's clear where to go for docs?
-
-
You can pass
id=12321
tocreate_review_request()
(in fact, it's important to do that — old code may not though). -
-
-
-
-
-
-
I just noticed that Christian beat me to the review, so hopefully these aren't duplicates.
Otherwise, I manually tested the integration on my own discord server, and it works wonderfully.
I also ran the tests and all of them worked on RB3 but strangely there are 2 failing test cases on RB4.
However, these are already documented on the Notion documents. -
-
I noticed that other review board files have 2 lines below the import statements. So I think that you should have 2 lines after the last import statement for your
logger = logging.getLogger(__name__)
and then 2 lines below before the class definition.
- Change Summary:
-
Address feedbacks from Christian and Jacob
- Commits:
-
Summary ID Author 1c92b2dda999f80ff90c8b40bfcdc57c028796de HailanXyouknow c939590f76e4cbd43cf403d88185b2290ef88d1c HailanXyouknow - Diff:
-
Revision 12 (+3860 -60)
- Change Summary:
-
Fix spacing issue
- Commits:
-
Summary ID Author c939590f76e4cbd43cf403d88185b2290ef88d1c HailanXyouknow 674487d35a849c39b33d609f6c05ecb1fafa5bdb HailanXyouknow - Diff:
-
Revision 13 (+3862 -60)
Checks run (2 succeeded)
-
-
I have to add .encode('UTF-8) at the end of this line to get it to work for some reason. Running into this issue when I try to get a message to show up on discord:
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
Other than that, tested it and works well!
- Change Summary:
-
Addressed Ruonan's feedback.
- Testing Done:
-
~ Added unit tests in discord/tests.py and they pass in RB3. RB4 has two
~ exceptions (please see below). ~ Please also see my RB4 Discord Integration demo at ~ https://www.youtube.com/watch?v=vKY1b60UkmA&ab_channel=ReviewBoard ~ Added unit tests in discord/tests.py and they pass in RB3 virtual
~ environment. RB4 has two exceptions (please see below). ~ ~ Tested it manually in reviewboard 3.0.x and 4.0.x.
- I've also tested it manually in RB3. Issues that still need to be addressed:
-
Add assets (e.g. logos, trophies, etc.) at this location:
https://static.reviewboard.org/integration-assets/discord
-
It has the same problem as the Slack and Mattermost Integration:
two of the unit tests are complaining about this image here in RB4 -
/var/folders/f1/r8mpbfkd321804b47_tgytgw0000gn/T/rb-tests-EQOxMU/
static/rb/images/logo.png
-
- Commits:
-
Summary ID Author 674487d35a849c39b33d609f6c05ecb1fafa5bdb HailanXyouknow 905081342dbed39d3af26f8a34e36c3a781e9332 HailanXyouknow - Diff:
-
Revision 14 (+3862 -60)
Checks run (2 succeeded)
-
Just a few small things, and then this will land :)
-
-
This has two spellings of "Webhook": "Webhook" and "WebHook". Not your fault — we're inconsistent in places as well. I think we should keep any non-title versions "webhook" (no capitalizations), as this is more standard these days.
-
-
-
-
To check, is there a reason we use this User-Agent? If so, we should document this. If not, we shouldn't include it.
-
-
-
-
-
It's best to avoid one-line dictionaries with multiple keys, as it becomes harder to add to. Let's do:
return { 'attachments': [attachments], 'icon_url': integration.LOGO_URL, }
Also note the alphabetical order.
- Change Summary:
-
Address Christian's feedback
- Commits:
-
Summary ID Author 905081342dbed39d3af26f8a34e36c3a781e9332 HailanXyouknow b1cff2eb4fe7f953704b96c252b7b96564b31464 HailanXyouknow - Diff:
-
Revision 15 (+3872 -60)