mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
automatic notifications clearing
This commit is contained in:
parent
80077786cf
commit
5db190d6b8
5 changed files with 12 additions and 1 deletions
|
@ -137,6 +137,7 @@ defmodule Philomena.Forums do
|
|||
|> Repo.delete()
|
||||
end
|
||||
|
||||
def clear_notification(_forum, nil), do: nil
|
||||
def clear_notification(forum, user) do
|
||||
Notifications.delete_unread_notification("Forum", forum.id, user)
|
||||
end
|
||||
|
|
|
@ -290,6 +290,7 @@ defmodule Philomena.Images do
|
|||
|> Repo.delete()
|
||||
end
|
||||
|
||||
def clear_notification(_image, nil), do: nil
|
||||
def clear_notification(image, user) do
|
||||
Notifications.delete_unread_notification("Image", image.id, user)
|
||||
end
|
||||
|
|
|
@ -190,6 +190,7 @@ defmodule Philomena.Topics do
|
|||
|> Repo.delete()
|
||||
end
|
||||
|
||||
def clear_notification(_topic, nil), do: nil
|
||||
def clear_notification(topic, user) do
|
||||
Notifications.delete_unread_notification("Topic", topic.id, user)
|
||||
end
|
||||
|
|
|
@ -29,6 +29,9 @@ defmodule PhilomenaWeb.ImageController do
|
|||
|
||||
def show(conn, %{"id" => _id}) do
|
||||
image = conn.assigns.image
|
||||
user = conn.assigns.current_user
|
||||
|
||||
Images.clear_notification(image, user)
|
||||
|
||||
comments =
|
||||
Comment
|
||||
|
|
|
@ -2,7 +2,7 @@ defmodule PhilomenaWeb.TopicController do
|
|||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.{Forums.Forum, Topics.Topic, Posts.Post, Polls.Poll, PollOptions.PollOption}
|
||||
alias Philomena.{Topics, Posts}
|
||||
alias Philomena.{Forums, Topics, Posts}
|
||||
alias Philomena.Textile.Renderer
|
||||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
@ -22,6 +22,11 @@ defmodule PhilomenaWeb.TopicController do
|
|||
|> preload([:user, poll: :options])
|
||||
|> Repo.one()
|
||||
|
||||
user = conn.assigns.current_user
|
||||
|
||||
Topics.clear_notification(topic, user)
|
||||
Forums.clear_notification(forum, user)
|
||||
|
||||
conn = conn |> assign(:topic, topic)
|
||||
%{page_number: page} = conn.assigns.pagination
|
||||
|
||||
|
|
Loading…
Reference in a new issue