-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Endpoints for Notifications #950
Add Endpoints for Notifications #950
Conversation
- Create Notifications module and NotificationType model - Start migration for adding notifications - No functionalities added yet only template code
notification entry
Changes: * Replaced is_enable to is_enabled for Notification Preferences * Update default is_enabled to true for Notifcation Types
`import_config` must always appear at the bottom for environment specific configurations to be applied correctly. All configurations after this line will overwrite configurations that exists in the environment specific ones.
- remove auto-generated controllers and views that are not used
If user preference has no time option, use the time_option from notification_config instead. This is so that the behaviour of these users with no preferences would always follow the default chosen by the course admin
* Removed extra unused route
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick work! However, I think the design needs major changes.
First of all, try to follow the current routing scopes, if a notification belongs to a course, semantically it should be under /course. In that way, you will naturally pipe through authentication checks, course checks sand staff checks.
Second, please separate admin routes from student routes (or do you want to separate them from staff also?). Do think about the privilege of each route. The backend needs to be intact without the assumption of the well-behaviour of the frontend.
Lastly, please clean up unnecessary comments and use query styles in the piping fashion(which aligns with the current code base). Try to use Logger instead of IO for logging.
@@ -169,6 +169,19 @@ defmodule CadetWeb.Router do | |||
) | |||
end | |||
|
|||
# Notifications endpoints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these APIs being called from the frontend? Why are they not piped through authentication and course-specific assignment? I am not sure what might happen here. If some request is fired from a student that already has his log in session expired or if the student changed course(which might lead to some cache issue or privilege issue)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please separate the admin routes from the student routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be potentially very dangerous as some students may edit the configs that only admins can edit. We should not assume that the frontend will behave as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or is there any justification that these APIs do not need any authentication at all?
if length(ungraded_submissions) < ungraded_threshold do | ||
IO.puts("[AVENGER_BACKLOG] below threshold!") | ||
else | ||
IO.puts("[AVENGER_BACKLOG] SENDING_OUT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is a logger better here?
query = | ||
from(n in Cadet.Notifications.NotificationConfig, | ||
where: n.course_id == ^course_id | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the query here in a different style?
ntype.for_staff == ^is_staff and | ||
n.course_id == ^cr.course_id and | ||
(p.course_reg_id == ^cr.id or is_nil(p.course_reg_id)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A different style of query. Please stick to piping. |>
# end | ||
|
||
# case Repo.delete(time_option) do | ||
# JUNYI AND SANTOSH: NOT DEFINED??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please clean up unused comments as well.
Closing as per offline discussion. |
Changes
Adding extra endpoints needed for notifications