mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 14:47:58 +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()
|
|> Repo.delete()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_notification(_forum, nil), do: nil
|
||||||
def clear_notification(forum, user) do
|
def clear_notification(forum, user) do
|
||||||
Notifications.delete_unread_notification("Forum", forum.id, user)
|
Notifications.delete_unread_notification("Forum", forum.id, user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -290,6 +290,7 @@ defmodule Philomena.Images do
|
||||||
|> Repo.delete()
|
|> Repo.delete()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_notification(_image, nil), do: nil
|
||||||
def clear_notification(image, user) do
|
def clear_notification(image, user) do
|
||||||
Notifications.delete_unread_notification("Image", image.id, user)
|
Notifications.delete_unread_notification("Image", image.id, user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -190,6 +190,7 @@ defmodule Philomena.Topics do
|
||||||
|> Repo.delete()
|
|> Repo.delete()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_notification(_topic, nil), do: nil
|
||||||
def clear_notification(topic, user) do
|
def clear_notification(topic, user) do
|
||||||
Notifications.delete_unread_notification("Topic", topic.id, user)
|
Notifications.delete_unread_notification("Topic", topic.id, user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,9 @@ defmodule PhilomenaWeb.ImageController do
|
||||||
|
|
||||||
def show(conn, %{"id" => _id}) do
|
def show(conn, %{"id" => _id}) do
|
||||||
image = conn.assigns.image
|
image = conn.assigns.image
|
||||||
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
|
Images.clear_notification(image, user)
|
||||||
|
|
||||||
comments =
|
comments =
|
||||||
Comment
|
Comment
|
||||||
|
|
|
@ -2,7 +2,7 @@ defmodule PhilomenaWeb.TopicController do
|
||||||
use PhilomenaWeb, :controller
|
use PhilomenaWeb, :controller
|
||||||
|
|
||||||
alias Philomena.{Forums.Forum, Topics.Topic, Posts.Post, Polls.Poll, PollOptions.PollOption}
|
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.Textile.Renderer
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
@ -22,6 +22,11 @@ defmodule PhilomenaWeb.TopicController do
|
||||||
|> preload([:user, poll: :options])
|
|> preload([:user, poll: :options])
|
||||||
|> Repo.one()
|
|> Repo.one()
|
||||||
|
|
||||||
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
|
Topics.clear_notification(topic, user)
|
||||||
|
Forums.clear_notification(forum, user)
|
||||||
|
|
||||||
conn = conn |> assign(:topic, topic)
|
conn = conn |> assign(:topic, topic)
|
||||||
%{page_number: page} = conn.assigns.pagination
|
%{page_number: page} = conn.assigns.pagination
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue