Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upNotifications #2591
Conversation
scopeInfinity
added some commits
Jul 28, 2018
scopeInfinity
changed the title
[WIP] Notifications
Notifications
Jul 28, 2018
scopeInfinity
requested a review
from
andrewaikens87
Jul 28, 2018
scopeInfinity
and others
added some commits
Jul 28, 2018
KevinMackenzie
reviewed
Jul 30, 2018
-- | ||
-- Name: notifications; Type: TABLE; Schema: public; Owner: - | ||
-- | ||
CREATE TABLE notifications ( |
This comment was marked as resolved.
This comment was marked as resolved.
KevinMackenzie
Jul 30, 2018
Contributor
We might want to add a Notification
class in the Model to represent this table
KevinMackenzie
reviewed
Jul 30, 2018
type notifications_type NOT NULL, | ||
metadata TEXT NOT NULL, | ||
content TEXT NOT NULL, | ||
from_user_id VARCHAR(255) NOT NULL, |
This comment has been minimized.
This comment has been minimized.
KevinMackenzie
Jul 30, 2018
Contributor
we may want this to be null so that we can have notifications that don't originate from a user
scopeInfinity
added some commits
Jul 30, 2018
This comment has been minimized.
This comment has been minimized.
Thanks, @KevinMackenzie |
scopeInfinity
added some commits
Jul 30, 2018
KevinMackenzie
reviewed
Jul 30, 2018
protected $notify_content; | ||
/** @property @var string Notification information about redirection link */ | ||
protected $notify_metadata; | ||
/** @property @var string Should $notify_source be ignored from $notify_target */ |
This comment has been minimized.
This comment has been minimized.
KevinMackenzie
reviewed
Jul 30, 2018
private function handleForum($details) { | ||
switch ($details['type']) { | ||
case 'new_announcement': | ||
$this->setNotifyMetadata(json_encode(array('component' => 'forum', 'page' => 'view_thread', 'thread_id' => $details['thread_id']))); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
scopeInfinity
Aug 1, 2018
Author
Member
The initial idea was to store url info in the metadata.
So that using $this->core->buildUrl
we can resolve metadata into url, easily.
KevinMackenzie
reviewed
Jul 30, 2018
* | ||
* @param array $details | ||
*/ | ||
private function handleForum($details) { |
This comment was marked as resolved.
This comment was marked as resolved.
KevinMackenzie
Jul 30, 2018
Contributor
Instead of a catch-all handleForum
function, split each switch case into its own function that takes explicitly named parameters.
KevinMackenzie
reviewed
Jul 30, 2018
$this->pushNotification($source_user_id, $type, $metadata, $content, $target_users_query, $additional_param, $ignore_self); | ||
} | ||
public function getUserNotifications($user_id, $show_all){ |
This comment has been minimized.
This comment has been minimized.
KevinMackenzie
Jul 30, 2018
Contributor
This function should return an array of Notification
objects
KevinMackenzie
reviewed
Jul 30, 2018
* @param string $additional_param Additional parameters to be appended | ||
* @param bool $ignore_self Should ignore $source_user_id from target users | ||
*/ | ||
public function pushNotification($source_user_id, $type, $metadata, $content, $target_users_query, $additional_param, $ignore_self){ |
This comment has been minimized.
This comment has been minimized.
KevinMackenzie
Jul 30, 2018
Contributor
We should have one pushNotification
function in the DatabaseQueries
class that takes a Notification
model instance and switches which operation occurs based on the Notification
s state.
scopeInfinity
added some commits
Aug 1, 2018
andrewaikens87
reviewed
Aug 2, 2018
|
||
{% if notifications is empty %} | ||
<tr> | ||
<td colspan="8">No notification found</td> |
This comment has been minimized.
This comment has been minimized.
andrewaikens87
Aug 2, 2018
•
Member
It might be nice to have "No new notifications." be displayed for if notifications is empty when looking at the unread notifications and either "No notification found." or "No notifications." for the view all option.
andrewaikens87
reviewed
Aug 2, 2018
private function notificationsHandler() { | ||
$user_id = $this->core->getUser()->getId(); | ||
if(!empty($_GET['action'])){ | ||
if($_GET['action'] == 'open_notification' && is_numeric($_GET['nid']) && $_GET['nid'] >= 1) { |
This comment has been minimized.
This comment has been minimized.
andrewaikens87
Aug 2, 2018
Member
This will throw an undefined index if action
is defined but nid
is not
andrewaikens87
reviewed
Aug 2, 2018
} | ||
private function actAsForumReplyNotification($thread_id, $post_content, $target) { | ||
// TODO: Redirect to post itself |
This comment has been minimized.
This comment has been minimized.
andrewaikens87
Aug 2, 2018
•
Member
In the URL you can simply put #<post_id> at the end, try using the search feature and inspecting element on a resulting post for an example.
andrewaikens87
reviewed
Aug 2, 2018
<h2>Notifications</h2> | ||
<table class="table table-bordered persist-area"> | ||
<tr class="info persist-header"> | ||
<td colspan="8" style="text-align: center">Course: {{ course }}</td> |
This comment has been minimized.
This comment has been minimized.
andrewaikens87
Aug 2, 2018
Member
It might be better to have "New notifications" and "All notifications" for the table since when a user is currently viewing the notifications page it is within a course.
This comment has been minimized.
This comment has been minimized.
Looks like you've addressed all the changes I suggested. I tested it out a bit and it looks like its working, but @andrewaikens87 is going to take another look at it. |
KevinMackenzie
requested changes
Aug 2, 2018
It all seems to work as desired. There are just a few organizational things that should be straight-forward to fix. |
$results[] = new Notification($this->core, array( | ||
'view_only' => true, | ||
'id' => $row['id'], | ||
'component' => $row['type'], |
This comment has been minimized.
This comment has been minimized.
KevinMackenzie
Aug 2, 2018
Contributor
Its confusing that you have a type
field in the database that gets converted to a component
field in the model, but that model also takes a type
parameter that means something different. If you make type
consistent with type
in the database and maybe change type
as it exists in php now to action
it would be a lot more clear.
@@ -694,4 +694,13 @@ public function deleteGradeableForm() { | |||
return $this->core->getOutput()->renderTwigTemplate("navigation/DeleteGradeableForm.twig"); | |||
} | |||
public function listNotifications($notifications, $show_all) { |
This comment has been minimized.
This comment has been minimized.
KevinMackenzie
Aug 2, 2018
Contributor
We could probably put this in a NotificationsView
class or just call this code in-line where this function gets invoked (NavigationController
). It doesn't make much sense to have it be in the Navigation View
scopeInfinity
added some commits
Aug 2, 2018
KevinMackenzie
approved these changes
Aug 2, 2018
andrewaikens87
approved these changes
Aug 3, 2018
Good except for the failing travis test, I can help tomorrow if it is not fixed by then |
scopeInfinity commentedJul 28, 2018
•
edited
Notifications System #2489