fixes after rebase

This commit is contained in:
Alexander Strizhakov 2020-11-20 10:33:27 +03:00
parent af6725121f
commit f1781c14eb
No known key found for this signature in database
GPG Key ID: 022896A53AEF1381
5 changed files with 28 additions and 28 deletions

View File

@ -5,6 +5,9 @@
defmodule Pleroma.Notification do defmodule Pleroma.Notification do
use Ecto.Schema use Ecto.Schema
import Ecto.Query
import Ecto.Changeset
alias Ecto.Multi alias Ecto.Multi
alias Pleroma.Activity alias Pleroma.Activity
alias Pleroma.FollowingRelationship alias Pleroma.FollowingRelationship
@ -20,15 +23,26 @@ defmodule Pleroma.Notification do
alias Pleroma.Web.Push alias Pleroma.Web.Push
alias Pleroma.Web.Streamer alias Pleroma.Web.Streamer
import Ecto.Query
import Ecto.Changeset
require Logger require Logger
@type t :: %__MODULE__{}
@include_muted_option :with_muted @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 schema "notifications" do
field(:seen, :boolean, default: false) field(:seen, :boolean, default: false)
# This is an enum type in the database. If you add a new notification type, # 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) |> Repo.aggregate(:count, :id)
end end
@notification_types ~w{ @spec types() :: [String.t()]
favourite def types, do: @types
follow
follow_request
mention
move
pleroma:chat_mention
pleroma:emoji_reaction
pleroma:report
reblog
}
@notification_types_excluding_chat List.delete(@notification_types, "pleroma:chat_mention") @spec types_excluding_chat_and_report() :: [String.t()]
def types_excluding_chat_and_report, do: @types_excluding_chat_and_report
def types, do: @notification_types
def types_excluding_chat, do: @notification_types_excluding_chat
def changeset(%Notification{} = notification, attrs) do def changeset(%Notification{} = notification, attrs) do
notification notification
|> cast(attrs, [:seen, :type]) |> cast(attrs, [:seen, :type])
|> validate_inclusion(:type, @notification_types) |> validate_inclusion(:type, @types)
end end
@spec last_read_query(User.t()) :: Ecto.Queryable.t() @spec last_read_query(User.t()) :: Ecto.Queryable.t()

View File

@ -46,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationController do
params = params =
params params
|> Map.new(fn {k, v} -> {to_string(k), v} end) |> 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) notifications = MastodonAPI.get_notifications(user, params)

View File

@ -25,7 +25,6 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEControllerTest do
user = User.get_cached_by_ap_id(user.ap_id) user = User.get_cached_by_ap_id(user.ap_id)
assert user.mastofe_settings == %{"programming" => "socks"} assert user.mastofe_settings == %{"programming" => "socks"}
end end
end
describe "index/2 redirections" do describe "index/2 redirections" do
setup %{conn: conn} do setup %{conn: conn} do

View File

@ -124,7 +124,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
notification_settings = %{ notification_settings = %{
block_from_strangers: false, block_from_strangers: false,
hide_notification_contents: false hide_notification_contents: false,
followers: true, followers: true,
follows: true, follows: true,
non_followers: true, non_followers: true,

View File

@ -27,9 +27,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn conn
|> put("/api/pleroma/notification_settings", %{ |> put("/api/pleroma/notification_settings", %{
"block_from_strangers" => true, "block_from_strangers" => true,
"bar" => 1
"followers" => false,
"bar" => 1, "bar" => 1,
"followers" => false,
"exclude_types" => ["follow"] "exclude_types" => ["follow"]
}) })
|> json_response(:ok) |> json_response(:ok)
@ -38,7 +37,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
assert %Pleroma.User.NotificationSetting{ assert %Pleroma.User.NotificationSetting{
block_from_strangers: true, block_from_strangers: true,
hide_notification_contents: false hide_notification_contents: false,
followers: false, followers: false,
follows: true, follows: true,
non_follows: true, non_follows: true,