fixes after rebase
This commit is contained in:
parent
af6725121f
commit
f1781c14eb
@ -5,6 +5,9 @@
|
||||
defmodule Pleroma.Notification do
|
||||
use Ecto.Schema
|
||||
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Ecto.Multi
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.FollowingRelationship
|
||||
@ -20,15 +23,26 @@ defmodule Pleroma.Notification do
|
||||
alias Pleroma.Web.Push
|
||||
alias Pleroma.Web.Streamer
|
||||
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
require Logger
|
||||
|
||||
@type t :: %__MODULE__{}
|
||||
|
||||
@include_muted_option :with_muted
|
||||
|
||||
@types ~w{
|
||||
favourite
|
||||
follow
|
||||
follow_request
|
||||
mention
|
||||
move
|
||||
pleroma:chat_mention
|
||||
pleroma:emoji_reaction
|
||||
pleroma:report
|
||||
reblog
|
||||
}
|
||||
|
||||
@types_excluding_chat_and_report @types -- ~w(pleroma:chat_mention pleroma:report)
|
||||
|
||||
@type t :: %__MODULE__{}
|
||||
|
||||
schema "notifications" do
|
||||
field(:seen, :boolean, default: false)
|
||||
# This is an enum type in the database. If you add a new notification type,
|
||||
@ -62,28 +76,16 @@ defmodule Pleroma.Notification do
|
||||
|> Repo.aggregate(:count, :id)
|
||||
end
|
||||
|
||||
@notification_types ~w{
|
||||
favourite
|
||||
follow
|
||||
follow_request
|
||||
mention
|
||||
move
|
||||
pleroma:chat_mention
|
||||
pleroma:emoji_reaction
|
||||
pleroma:report
|
||||
reblog
|
||||
}
|
||||
@spec types() :: [String.t()]
|
||||
def types, do: @types
|
||||
|
||||
@notification_types_excluding_chat List.delete(@notification_types, "pleroma:chat_mention")
|
||||
|
||||
def types, do: @notification_types
|
||||
|
||||
def types_excluding_chat, do: @notification_types_excluding_chat
|
||||
@spec types_excluding_chat_and_report() :: [String.t()]
|
||||
def types_excluding_chat_and_report, do: @types_excluding_chat_and_report
|
||||
|
||||
def changeset(%Notification{} = notification, attrs) do
|
||||
notification
|
||||
|> cast(attrs, [:seen, :type])
|
||||
|> validate_inclusion(:type, @notification_types)
|
||||
|> validate_inclusion(:type, @types)
|
||||
end
|
||||
|
||||
@spec last_read_query(User.t()) :: Ecto.Queryable.t()
|
||||
|
@ -46,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationController do
|
||||
params =
|
||||
params
|
||||
|> Map.new(fn {k, v} -> {to_string(k), v} end)
|
||||
|> Map.put_new("include_types", Pleroma.Notification.types_excluding_chat())
|
||||
|> Map.put_new("include_types", Pleroma.Notification.types_excluding_chat_and_report())
|
||||
|
||||
notifications = MastodonAPI.get_notifications(user, params)
|
||||
|
||||
|
@ -25,7 +25,6 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEControllerTest do
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
assert user.mastofe_settings == %{"programming" => "socks"}
|
||||
end
|
||||
end
|
||||
|
||||
describe "index/2 redirections" do
|
||||
setup %{conn: conn} do
|
||||
|
@ -124,7 +124,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||
|
||||
notification_settings = %{
|
||||
block_from_strangers: false,
|
||||
hide_notification_contents: false
|
||||
hide_notification_contents: false,
|
||||
followers: true,
|
||||
follows: true,
|
||||
non_followers: true,
|
||||
|
@ -27,9 +27,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
||||
conn
|
||||
|> put("/api/pleroma/notification_settings", %{
|
||||
"block_from_strangers" => true,
|
||||
"bar" => 1
|
||||
"followers" => false,
|
||||
"bar" => 1,
|
||||
"followers" => false,
|
||||
"exclude_types" => ["follow"]
|
||||
})
|
||||
|> json_response(:ok)
|
||||
@ -38,7 +37,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
||||
|
||||
assert %Pleroma.User.NotificationSetting{
|
||||
block_from_strangers: true,
|
||||
hide_notification_contents: false
|
||||
hide_notification_contents: false,
|
||||
followers: false,
|
||||
follows: true,
|
||||
non_follows: true,
|
||||
|
Loading…
Reference in New Issue
Block a user