-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for notifications on keywords, closes #142
- Loading branch information
Jan Henning Thorsen
committed
Feb 20, 2017
1 parent
f5d0a79
commit 9a31ef7
Showing
10 changed files
with
70 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,10 @@ ok -e $settings_file, 'created storage file'; | |
is_deeply( | ||
$user->TO_JSON, | ||
{ | ||
email => '[email protected]', | ||
registered => Mojo::Date->new($main::time)->to_datetime, | ||
unread => 0 | ||
email => '[email protected]', | ||
highlight_keywords => [], | ||
registered => Mojo::Date->new($main::time)->to_datetime, | ||
unread => 0 | ||
}, | ||
'TO_JSON' | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,18 @@ is @{$t->tx->res->json->{notifications}}, $n + 1, 'only one new notification'; | |
is int(grep { $_->{highlight} } @events), 2, 'marked as highlight'; | ||
is int(grep { !$_->{highlight} } @events), 2, 'not marked as highlight'; | ||
|
||
$user->highlight_keywords(['normal', 'yikes']); | ||
$connection->_event_privmsg( | ||
{ | ||
event => 'privmsg', | ||
prefix => '[email protected]', | ||
params => ['#convos', 'Or what about a normal message in a channel?'], | ||
} | ||
); | ||
|
||
$stop_at_n_events = 5; | ||
$ws->ua->ioloop->start; | ||
$t->get_ok('/api/notifications')->status_is(200); | ||
is @{$t->tx->res->json->{notifications}}, $n + 2, 'notification on custom keyword'; | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,19 +36,38 @@ my $registered = $t->tx->res->json->{registered}; | |
|
||
$t->post_ok('/api/user', json => {})->status_is(200); | ||
|
||
$t->get_ok('/api/user')->status_is(200) | ||
->json_is('', {email => '[email protected]', registered => $registered, unread => 0}); | ||
$t->get_ok('/api/user')->status_is(200)->json_is( | ||
'', | ||
{ | ||
email => '[email protected]', | ||
highlight_keywords => [], | ||
registered => $registered, | ||
unread => 0 | ||
} | ||
); | ||
|
||
$t->post_ok('/api/user', json => {highlight_keywords => ['foo']})->status_is(200); | ||
$t->get_ok('/api/user')->status_is(200)->json_is( | ||
'', | ||
{ | ||
email => '[email protected]', | ||
highlight_keywords => ['foo'], | ||
registered => $registered, | ||
unread => 0 | ||
} | ||
); | ||
|
||
$t->app->core->get_user('[email protected]')->unread(4); | ||
$t->get_ok('/api/user?connections=true&dialogs=true¬ifications=true')->status_is(200)->json_is( | ||
'', | ||
{ | ||
connections => [], | ||
dialogs => [], | ||
notifications => [], | ||
email => '[email protected]', | ||
registered => $registered, | ||
unread => 4, | ||
connections => [], | ||
dialogs => [], | ||
highlight_keywords => ['foo'], | ||
notifications => [], | ||
email => '[email protected]', | ||
registered => $registered, | ||
unread => 4, | ||
} | ||
); | ||
|
||
|