aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
...
| * | | | | | | | | | | | Incidents: pass `actioned_by` to `archive`Gravatar kwzrd2020-06-30-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an important piece of information that shall be relayed.
| * | | | | | | | | | | | Incidents: revert latest 2 commitsGravatar kwzrd2020-06-30-75/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decision was made to use embeds to archive incidents instead of webhooking the raw message. As such, we're reverting the branch to a state from which the adjustments will be easier to make. Reverted commits: * a8d179d9b04f54b20c5e870bcfa85c78c42c8dca * 6fa8caed037b247a7c194f58a4635de7dae21fd2
| * | | | | | | | | | | | Incidents: append `actioned_by` to webhook usernameGravatar kwzrd2020-06-21-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Incident author and the moderator who actioned report are now passed through `make_username` to create the webhook username. Tests adjusted as appropriate.
| * | | | | | | | | | | | Incidents: implement `make_username` helperGravatar kwzrd2020-06-21-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The justification is to incorporate the `actioned_by` name into the username in some way, and so the logical thing to do is to abstract this process into a helper so that it can easily be adjusted in the future. For now, I've chosen to separate the names by a pipe. Discord webhook username cannot exceed 80 characters in length, and so we cap it at this length by default. This is seen as more of an edge-case, but it should be accounted for, as we're not joining two names. The `max_length` param is configurable primarily for testing purposes, it probably should never be passed explicitly. This commit also provides two tests for the function.
| * | | | | | | | | | | | Incidents tests: assert webhook username is de-clydedGravatar kwzrd2020-06-20-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See: a8b4e394d9da57287cd9497cd9bb0a97fa467e84
| * | | | | | | | | | | | Incidents: de-clyde archive webhook usernameGravatar kwzrd2020-06-20-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With PR #1009 merged, we now apply the same fix to our relay function. This prevents the "clyde" word from sneaking into the webhook username, which is forbidden and will return a 400.
| * | | | | | | | | | | | Merge branch 'origin/master' into kwzrd/incidentsGravatar kwzrd2020-06-20-24/+105
| |\ \ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the `sub_clyde` function, which we'll apply to our webhook.
| * | | | | | | | | | | | | Incidents tests: remove unnecessary patchGravatar kwzrd2020-06-20-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is already being patched at class-level.
| * | | | | | | | | | | | | Incidents: try-except Signal creationGravatar kwzrd2020-06-20-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by Mark during review. This follows the "ask for forgiveness rather than permission" paradigm, ends up being less code to read, and may be seen as more logical / safer. The `ALLOWED_EMOJI` set was renamed to `ALL_SIGNALS` as this now better communicates the set's purpose. Tests adjusted as appropriate. Co-authored-by: MarkKoz <[email protected]>
| * | | | | | | | | | | | | Incidents: simplify set operation in `has_signals`Gravatar kwzrd2020-06-20-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using `issubset` is a much simpler & more readable way of expressing the relationship between the two sets. Suggested by Mark during review. Co-authored-by: MarkKoz <[email protected]>
| * | | | | | | | | | | | | Incidents: make crawl limit & sleep module-level constantsGravatar kwzrd2020-06-20-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested during review. Co-authored-by: ks129 <[email protected]> Co-authored-by: Joseph Banks <[email protected]>
| * | | | | | | | | | | | | Incidents: make logs contain the message id they pertain toGravatar kwzrd2020-06-20-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by Mark during review. Co-authored-by: MarkKoz <[email protected]>
| * | | | | | | | | | | | | Incidents: remove redundant `exc_info` passingGravatar kwzrd2020-06-20-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pointed out by Mark during review that this is unnecessary, as logging using `exception` automatically appends the `exc_info` of the handled exception when done in an except block. Co-authored-by: MarkKoz <[email protected]>
| * | | | | | | | | | | | | Incidents: reduce excessive whitespaceGravatar kwzrd2020-06-19-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is way too spacious for how little is happening here. Suggested by ks129. Co-authored-by: ks129 <[email protected]>
| * | | | | | | | | | | | | Incidents: annotate possible None typeGravatar kwzrd2020-06-19-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Caught during review by ks129. Co-authored-by: ks129 <[email protected]>
| * | | | | | | | | | | | | Incidents: remove broad noqaGravatar kwzrd2020-06-19-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was originally in place to silence a PyCharm warning regarding accessing the private attributes. However, since there is no corresponding error code to specify, the noqa will silence any linter warning, which is potentially dangerous, and seems to be bad practice.
| * | | | | | | | | | | | | Incidents: review log levels; use `trace` where appropriateGravatar kwzrd2020-06-19-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Logs useful when observing the internals but too verbose for DEBUG are reduced to TRACE.
| * | | | | | | | | | | | | Incidents tests: write tests for `on_raw_reaction_add`Gravatar kwzrd2020-06-19-0/+128
| | | | | | | | | | | | | |
| * | | | | | | | | | | | | Incidents tests: write tests for `crawl_incidents`Gravatar kwzrd2020-06-19-0/+58
| | | | | | | | | | | | | |
| * | | | | | | | | | | | | Incidents tests: add helper for mocking async for-loopsGravatar kwzrd2020-06-19-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See the docstring. This does not make the ambition to be powerful enough to be included in `tests.helpers`, and is only intended for local purposes.
| * | | | | | | | | | | | | Merge branch 'origin/master' into kwzrd/incidentsGravatar kwzrd2020-06-19-251/+643
| |\ \ \ \ \ \ \ \ \ \ \ \ \
| * | | | | | | | | | | | | | Incidents tests: write tests for `process_event`Gravatar kwzrd2020-06-18-1/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also breaks the helpers import statement into a vertical list, as the amount of imports has grown too much. I still believe that this is a preferred alternative to accessing the helpers via module namespace, as we use them a lot, and the added visual noise would be annoying to read - their names are already descriptive enough.
| * | | | | | | | | | | | | | Incidents tests: write tests for `make_confirmation_task`Gravatar kwzrd2020-06-13-0/+35
| | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | Incidents tests: write tests for `on_message`Gravatar kwzrd2020-06-13-0/+27
| | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | Incidents tests: test non-404 error responseGravatar kwzrd2020-06-13-0/+20
| | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | Incidents: log error on non-404 responseGravatar kwzrd2020-06-13-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We do not wish to log 404 exceptions as those are expected, however, if something else goes wrong, we shouldn't silence it. This also removes the explicit None return as it only adds syntax noise.
| * | | | | | | | | | | | | | Incidents tests: write tests for `resolve_message`Gravatar kwzrd2020-06-13-0/+56
| | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | Incidents tests: move `mock_404` into module namespaceGravatar kwzrd2020-06-13-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will be useful for others tests as well.
| * | | | | | | | | | | | | | Incidents tests: write tests for `archive`Gravatar kwzrd2020-06-13-2/+63
| | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | Incidents tests: set up base class for `Incidents`Gravatar kwzrd2020-06-13-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For cleanliness, I've decided to make a separate class for each method. Since most tests will want to have an `Incident` instance ready, they can inherit the `setUp` from `TestIncidents`, which does not make any assertions on its own.
| * | | | | | | | | | | | | | Incidents tests: improve mock `Signal` name & move defGravatar kwzrd2020-06-13-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's make it clear that this is our own mock. We also move the definition to the top of the module.
| * | | | | | | | | | | | | | Incidents tests: use our own helper mocksGravatar kwzrd2020-06-13-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No reason to build own MagicMocks as we already have helpers that more accurately mimic the mocked behaviour.
| * | | | | | | | | | | | | | Incidents tests: write tests for module-level helpersGravatar kwzrd2020-06-12-0/+135
| | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | Incidents tests: create new test moduleGravatar kwzrd2020-06-12-0/+0
| | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | Merge branch 'origin/master' into kwzrd/incidentsGravatar kwzrd2020-06-12-22/+62
| |\ \ \ \ \ \ \ \ \ \ \ \ \ \
| * | | | | | | | | | | | | | | Incidents: extend documentationGravatar kwzrd2020-06-12-11/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a proper class docstring & small touch-ups to local comments where necessary.
| * | | | | | | | | | | | | | | Incidents: avoid lambda check; make regular functionGravatar kwzrd2020-06-12-5/+5
| | | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | | Incidents: log `event_lock` releaseGravatar kwzrd2020-06-12-0/+1
| | | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | | Incidents: do not process reaction events from botsGravatar kwzrd2020-06-12-2/+3
| | | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | | Incidents: implement `process_event` coroutineGravatar kwzrd2020-06-12-3/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This contains the main logic for handling reactions and glues all the helpers together. Unfortunately, gracefully handling everything that can go wrong in the process requires quite a lot of code ~ but, at least to me, it seems like this all should now be fairly safe. The idea to await the message delete event before releasing the lock was conceived by Ves, while Mark helped me refine it. Co-authored-by: Sebastiaan Zeeff <[email protected]> Co-authored-by: MarkKoz <[email protected]>
| * | | | | | | | | | | | | | | Incidents: implement `make_confirmation_task` methodGravatar kwzrd2020-06-12-0/+15
| | | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | | Incidents: implement `archive` methodGravatar kwzrd2020-06-12-1/+39
| | | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | | Incidents: implement reaction listenerGravatar kwzrd2020-06-12-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See docstring!
| * | | | | | | | | | | | | | | Incidents: implement `resolve_message`Gravatar kwzrd2020-06-12-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See docstring. The exception log is DEBUG level as failure does not necessarily indicate that we have done something wrong. We rely on the API to tell us that the message no longer exists in situations where we have 2 coroutines racing to archive the same message.
| * | | | | | | | | | | | | | | Incidents: make `crawl_incidents` smarterGravatar kwzrd2020-06-12-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The crawler now avoids making API calls for messages which: * Are not incidents * Already have all signals As a result, we can sleep only after making actual calls. This speeds up the task completion considerable, while also making it lighter on the API. Victory!
| * | | | | | | | | | | | | | | Incidents: move `add_signals` to module namespaceGravatar kwzrd2020-06-12-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looks like we'll need quite a few helpers, and I think it's cleaner to keep them at module level. It helps avoid the question of: what do I do if a staticmethod depends on another staticmethod?
| * | | | | | | | | | | | | | | Incidents: implement `has_signals` helperGravatar kwzrd2020-06-12-0/+6
| | | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | | Incidents: implement `own_reactions` helperGravatar kwzrd2020-06-12-1/+6
| | | | | | | | | | | | | | | |
| * | | | | | | | | | | | | | | Incidents: abstract incident checking into a helper methodGravatar kwzrd2020-06-12-24/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code is now basically self-documenting, the docstring is no longer necessary. The ultimate goal is to allow `crawl_incidents` to be more smart about which messages need to be passed to `add_signals`, so that it doesn't need to sleep after each message.
| * | | | | | | | | | | | | | | Incidents: add `event_lock` for simple event synchronizationGravatar kwzrd2020-06-12-1/+3
| | | | | | | | | | | | | | | |