Commit Graph

51 Commits

Author SHA1 Message Date
Bartłomiej Dach de52f0a80c
Decouple notifications websocket handling from chat operations
This is a prerequisite for https://github.com/ppy/osu/pull/25480.

The `WebSocketNotificationsClient` was tightly coupled to chat specifics
making it difficult to use in the second factor verification flow.
This commit's goal is to separate the websocket connection and message
handling concerns from specific chat logic concerns.
2024-01-25 14:47:29 +01:00
wooster0 cf5f0a2bdc Make chat commands case-insensitive
Would be nice if I accidentally have caps lock enabled and write "/HELP" it still works.
2024-01-04 15:06:10 +09:00
Bartłomiej Dach a2df123c6d
Add failing test case for fake (but still incorrectly allowed) protocol 2023-09-18 09:19:12 +02:00
Lukynka CZE 25926af782 add unit test 2023-09-14 17:46:42 +02:00
Bartłomiej Dach 4859b8c994
Add some extra text coverage against potential emoji-to-link misparses 2023-07-13 20:51:52 +02:00
Andrew Hong 71351d8982 I forgor to remove these 2023-07-13 05:06:23 -04:00
Andrew Hong 403a7aa000 0 links are expected 2023-07-13 04:28:35 -04:00
Andrew Hong 3d17a03dc6 Emojis now represented as "[emoji]" 2023-07-13 03:52:22 -04:00
Andrew Hong f44e6e510d 5 -> 4 2023-07-12 22:42:12 -04:00
Andrew Hong 3d256acfef Delete emoji test in TestLinkComplex 2023-07-12 21:40:49 -04:00
Andrew Hong 5a43de1ace Update test cases 2023-07-12 21:13:10 -04:00
Salman Ahmed 115cb0d297 Fix channel manager test scene not waiting for notifications client connection 2023-01-12 23:14:23 +03:00
Dean Herbert bf56f5f8c0 Show error message on attempting to open a URL with an unsupported protocol 2022-12-13 22:33:56 +09:00
Dan Balasescu 7bc8908ca9 Partial everything 2022-11-27 00:00:27 +09:00
Dean Herbert dde09d409b Merge branch 'master' into chat-silences 2022-11-12 21:00:56 +09:00
Dan Balasescu 6ac19615fa Fix test failure 2022-11-11 14:55:41 +09:00
Dan Balasescu fa18b5f701 Construct notifications client inside ChannelManager 2022-11-04 18:51:00 +09:00
Dan Balasescu 063a8bdf9e Remove messages from silenced users 2022-11-02 17:13:14 +09:00
Dan Balasescu 5b25ef5f2f Construct notifications client via IAPIProvider 2022-11-01 21:34:34 +09:00
Dan Balasescu 169bcc2654 Use polling connector in tests 2022-10-28 18:08:08 +09:00
Dan Balasescu f8830c6850 Automated #nullable processing 2022-06-17 16:37:17 +09:00
Dean Herbert c661f2b059 Ensure `ChannelManager` has access to API from point of construction
Closes https://github.com/ppy/osu/issues/18451.
2022-06-08 19:15:23 +09:00
Dean Herbert 98aaf83177 Add a centralised constant for the osu URL schema protocol 2022-02-18 15:57:37 +09:00
Dan Balasescu ef66ec4622 Also fix MessageFormatter tests 2022-01-11 17:55:43 +09:00
Dean Herbert 0ecf5f201c Rename `User` to `APIUser` and move to correct namespace 2021-11-07 11:26:01 +09:00
Gagah Pangeran Rosfatiputra 7fcb01bdf1
add changelog links test 2021-10-12 09:57:46 +07:00
Opelkuh 8f698a42f7 Refactor `MarkChannelAsRead` test assert 2021-08-15 20:35:52 +02:00
Opelkuh 7d7c5c06f0 Fix code formatting 2021-08-15 16:02:25 +02:00
Opelkuh 2f9f1ba862 Add test for `ChannelManager.MarkChannelAsRead` 2021-08-15 15:44:23 +02:00
smoogipoo 1b2d00f796 Trigger successes 2021-06-29 20:13:39 +09:00
smoogipoo ca0eaab8e2 Add test 2021-06-29 16:30:46 +09:00
Joseph Madamba 8b2110c048 Add failing discussion links test 2021-06-20 21:36:08 -07:00
Dean Herbert a9f4bc6285 Never return a null argument
Enable nullable
2021-06-01 14:11:17 +09:00
Dean Herbert 1a05a5d2f0 Add test covering failure to resolve relative URLs 2021-06-01 13:50:04 +09:00
Dean Herbert 37a21cb192 Set static locally in test to ensure tests always run correctly 2021-02-12 21:30:02 +09:00
Dean Herbert 3799493536 Add test coverage of int match failures 2021-02-12 15:25:00 +09:00
Dean Herbert 955c9a2dd3 Add test coverage of beatmap link resolution 2021-02-12 15:17:39 +09:00
smoogipoo ab10732a78 Remove usages of null-forgiving operator 2020-06-09 22:13:48 +09:00
smoogipoo 8aa8d2c880 Resolve NREs 2020-06-03 16:59:37 +09:00
Bartłomiej Dach 661dfbefaf Change containment check to overlap
Due to scenarios wherein a formatted link ended up as part of a larger
raw link after parsing, change the containment check to an overlap check
and add appropriate tests for these edge cases.
2019-10-25 00:42:58 +02:00
Bartłomiej Dach cbd99cc767 Resolve link-in-link edge case
Testing with #6542 surfaced a crash scenario, caused by formatted links
that had URLs in the display text, for example

    [mean example - https://osu.ppy.sh](https://osu.ppy.sh)

In that case the outer Markdown link would get picked up once, and then
reduced to the link text when looking for other links, leading to it
being picked up again the second time when the raw link is found.

Add a check in the raw link parsing path that ensures that the found
URL is not a part of a bigger, pre-existing link.
2019-10-24 15:52:55 +02:00
Bartłomiej Dach a89ea78a7a Add extended testing for Markdown links
While reviewing #6542 it became apparent that there was another Markdown
link format variant, used in comments that came from the web API, called
the "inline link" style. It allows to specify the tooltip title within
the actual URL portion, as such:

    [link text](https://osu.ppy.sh "tooltip text")

Add tests with a couple of easy and trickier examples of such a format.
Moreover, add a new edge case of a Markdown link with a link inside
the display text, which during tests was detected to be problematic.
2019-10-24 15:52:55 +02:00
Bartłomiej Dach 08350a1aca Add parenthesis handling to old link format
Allow users to put both balanced round parentheses, as well as
unbalanced escaped ones, in old style link text. The implementation
is the same as for Markdown and new style links, except for swapping
all instances of

    \[\]

to

    \(\)

for obvious reasons (different type of parenthesis requiring escaping).
Tests also included.
2019-09-04 00:21:27 +02:00
Bartłomiej Dach f04add6d9e Add bracket handling to Markdown link format
Allow users to put both balanced brackets, as well as unbalanced
escaped ones, in Markdown link text. The implementation is the exact
same as in the case of new format links.

For completion's sake, tests also included.
2019-09-04 00:07:00 +02:00
Bartłomiej Dach a8f16503e2 Add backslash escaping to new link format
For users to be able to add square brackets inside of links using
the new format, the regular expression used for parsing those links
contained a balancing group, which can be used for matching pairs
of tokens (in this case, opening and closing brackets, in that order).
However, this means that users could not post links with unmatched
brackets inside of them (ie. ones that contain single brackets, or
a closing bracket and then an opening one). Allow for escaping opening
and closing brackets using the backslash character.

The change substitutes this old fragment of the regex in the display
text group:

    [^\[\]]*        // any character other than closing/opening bracket

for this one:

    (((?<=\\)[\[\]])|[^\[\]])*

The second pattern in the alternative remains the same; the first one
performs the escaping, as follows:

    (
        (?<=\\)     // positive lookbehind expression:
                    // this match will succeed, if the next expression
                    // is preceded by a single backslash
        [\[\]]      // either an opening or closing brace
    )

Since the entire display group is matched, unfortunately the lookbehind
expression does not actually strip the backslashes, so they are
manually stripped in handleMatches.

As demonstrated in the unit tests attached, this also allows balanced
brackets to be mixed with escaped ones.
2019-09-03 23:18:39 +02:00
Dean Herbert 1ccef61f7b Fix some missed instances of TestCase 2019-05-15 18:32:29 +09:00
Dean Herbert 8617aaa2a7 Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
Dean Herbert 32a74f95a5 Normalize all the line endings 2018-04-13 18:26:38 +09:00
Dean Herbert 2ffe16d3d2 Improve clarity and coverage of unit tests 2018-01-30 18:57:42 +09:00
Dean Herbert 1dbaf9b7a7 Add many more tests 2018-01-30 16:38:18 +09:00