Merge branch 'develop' into gun
This commit is contained in:
commit
b2eb1124d1
19 changed files with 197 additions and 50 deletions
|
|
@ -45,7 +45,8 @@ defmodule Pleroma.Config.TransferTask do
|
|||
|
||||
@spec load_and_update_env([ConfigDB.t()]) :: :ok | false
|
||||
def load_and_update_env(deleted \\ [], restart_pleroma? \\ true) do
|
||||
with true <- Pleroma.Config.get(:configurable_from_database),
|
||||
with {:configurable, true} <-
|
||||
{:configurable, Pleroma.Config.get(:configurable_from_database)},
|
||||
true <- Ecto.Adapters.SQL.table_exists?(Repo, "config"),
|
||||
started_applications <- Application.started_applications() do
|
||||
# We need to restart applications for loaded settings take effect
|
||||
|
|
@ -68,12 +69,15 @@ defmodule Pleroma.Config.TransferTask do
|
|||
if :pleroma in applications do
|
||||
List.delete(applications, :pleroma) ++ [:pleroma]
|
||||
else
|
||||
Restarter.Pleroma.rebooted()
|
||||
applications
|
||||
end
|
||||
|
||||
Enum.each(applications, &restart(started_applications, &1, Pleroma.Config.get(:env)))
|
||||
|
||||
:ok
|
||||
else
|
||||
{:configurable, false} -> Restarter.Pleroma.rebooted()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,19 +10,10 @@ defmodule Pleroma.Stats do
|
|||
|
||||
use GenServer
|
||||
|
||||
@init_state %{
|
||||
peers: [],
|
||||
stats: %{
|
||||
domain_count: 0,
|
||||
status_count: 0,
|
||||
user_count: 0
|
||||
}
|
||||
}
|
||||
|
||||
def start_link(_) do
|
||||
GenServer.start_link(
|
||||
__MODULE__,
|
||||
@init_state,
|
||||
nil,
|
||||
name: __MODULE__
|
||||
)
|
||||
end
|
||||
|
|
@ -53,8 +44,8 @@ defmodule Pleroma.Stats do
|
|||
peers
|
||||
end
|
||||
|
||||
def init(args) do
|
||||
{:ok, args}
|
||||
def init(_args) do
|
||||
{:ok, get_stat_data()}
|
||||
end
|
||||
|
||||
def handle_call(:force_update, _from, _state) do
|
||||
|
|
|
|||
|
|
@ -660,7 +660,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
{:ok, activity} <- insert(flag_data, local),
|
||||
{:ok, stripped_activity} <- strip_report_status_data(activity),
|
||||
:ok <- maybe_federate(stripped_activity) do
|
||||
Enum.each(User.all_superusers(), fn superuser ->
|
||||
User.all_superusers()
|
||||
|> Enum.filter(fn user -> not is_nil(user.email) end)
|
||||
|> Enum.each(fn superuser ->
|
||||
superuser
|
||||
|> Pleroma.Emails.AdminEmail.report(actor, account, statuses, content)
|
||||
|> Pleroma.Emails.Mailer.deliver_async()
|
||||
|
|
|
|||
|
|
@ -748,6 +748,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
def list_statuses(%{assigns: %{user: admin}} = conn, params) do
|
||||
godmode = params["godmode"] == "true" || params["godmode"] == true
|
||||
local_only = params["local_only"] == "true" || params["local_only"] == true
|
||||
with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
|
||||
{page, page_size} = page_params(params)
|
||||
|
||||
activities =
|
||||
|
|
@ -755,7 +756,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
"godmode" => godmode,
|
||||
"local_only" => local_only,
|
||||
"limit" => page_size,
|
||||
"offset" => (page - 1) * page_size
|
||||
"offset" => (page - 1) * page_size,
|
||||
"exclude_reblogs" => !with_reblogs && "true"
|
||||
})
|
||||
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -70,20 +70,21 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
end
|
||||
|
||||
def delete(activity_id, user) do
|
||||
with %Activity{data: %{"object" => _}} = activity <-
|
||||
Activity.get_by_id_with_object(activity_id),
|
||||
with {_, %Activity{data: %{"object" => _}} = activity} <-
|
||||
{:find_activity, Activity.get_by_id_with_object(activity_id)},
|
||||
%Object{} = object <- Object.normalize(activity),
|
||||
true <- User.superuser?(user) || user.ap_id == object.data["actor"],
|
||||
{:ok, _} <- unpin(activity_id, user),
|
||||
{:ok, delete} <- ActivityPub.delete(object) do
|
||||
{:ok, delete}
|
||||
else
|
||||
{:find_activity, _} -> {:error, :not_found}
|
||||
_ -> {:error, dgettext("errors", "Could not delete")}
|
||||
end
|
||||
end
|
||||
|
||||
def repeat(id_or_ap_id, user, params \\ %{}) do
|
||||
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
|
||||
with {_, %Activity{} = activity} <- {:find_activity, get_by_id_or_ap_id(id_or_ap_id)},
|
||||
object <- Object.normalize(activity),
|
||||
announce_activity <- Utils.get_existing_announce(user.ap_id, object),
|
||||
public <- public_announce?(object, params) do
|
||||
|
|
@ -93,21 +94,23 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
ActivityPub.announce(user, object, nil, true, public)
|
||||
end
|
||||
else
|
||||
{:find_activity, _} -> {:error, :not_found}
|
||||
_ -> {:error, dgettext("errors", "Could not repeat")}
|
||||
end
|
||||
end
|
||||
|
||||
def unrepeat(id_or_ap_id, user) do
|
||||
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id) do
|
||||
with {_, %Activity{} = activity} <- {:find_activity, get_by_id_or_ap_id(id_or_ap_id)} do
|
||||
object = Object.normalize(activity)
|
||||
ActivityPub.unannounce(user, object)
|
||||
else
|
||||
{:find_activity, _} -> {:error, :not_found}
|
||||
_ -> {:error, dgettext("errors", "Could not unrepeat")}
|
||||
end
|
||||
end
|
||||
|
||||
def favorite(id_or_ap_id, user) do
|
||||
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
|
||||
with {_, %Activity{} = activity} <- {:find_activity, get_by_id_or_ap_id(id_or_ap_id)},
|
||||
object <- Object.normalize(activity),
|
||||
like_activity <- Utils.get_existing_like(user.ap_id, object) do
|
||||
if like_activity do
|
||||
|
|
@ -116,15 +119,17 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
ActivityPub.like(user, object)
|
||||
end
|
||||
else
|
||||
{:find_activity, _} -> {:error, :not_found}
|
||||
_ -> {:error, dgettext("errors", "Could not favorite")}
|
||||
end
|
||||
end
|
||||
|
||||
def unfavorite(id_or_ap_id, user) do
|
||||
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id) do
|
||||
with {_, %Activity{} = activity} <- {:find_activity, get_by_id_or_ap_id(id_or_ap_id)} do
|
||||
object = Object.normalize(activity)
|
||||
ActivityPub.unlike(user, object)
|
||||
else
|
||||
{:find_activity, _} -> {:error, :not_found}
|
||||
_ -> {:error, dgettext("errors", "Could not unfavorite")}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -175,6 +175,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
for: user,
|
||||
with_direct_conversation_id: true
|
||||
)
|
||||
else
|
||||
_ -> {:error, :not_found}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -183,6 +185,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
with {:ok, %Activity{}} <- CommonAPI.delete(id, user) do
|
||||
json(conn, %{})
|
||||
else
|
||||
{:error, :not_found} = e -> e
|
||||
_e -> render_error(conn, :forbidden, "Can't delete this post")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
|
||||
def password_reset(nickname_or_email) do
|
||||
with true <- is_binary(nickname_or_email),
|
||||
%User{local: true} = user <- User.get_by_nickname_or_email(nickname_or_email),
|
||||
%User{local: true, email: email} = user when not is_nil(email) <-
|
||||
User.get_by_nickname_or_email(nickname_or_email),
|
||||
{:ok, token_record} <- Pleroma.PasswordResetToken.create_token(user) do
|
||||
user
|
||||
|> UserEmail.password_reset_email(token_record.token)
|
||||
|
|
@ -110,6 +111,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
false ->
|
||||
{:error, "bad user identifier"}
|
||||
|
||||
%User{local: true, email: nil} ->
|
||||
{:ok, :noop}
|
||||
|
||||
%User{local: false} ->
|
||||
{:error, "remote user"}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ defmodule Pleroma.Workers.Cron.DigestEmailsWorker do
|
|||
|
||||
from(u in inactive_users_query,
|
||||
where: fragment(~s(? ->'digest' @> 'true'), u.email_notifications),
|
||||
where: not is_nil(u.email),
|
||||
where: u.last_digest_emailed_at < datetime_add(^now, ^negative_interval, "day"),
|
||||
select: u
|
||||
)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ defmodule Pleroma.Workers.Cron.NewUsersDigestWorker do
|
|||
if users_and_statuses != [] do
|
||||
%{is_admin: true}
|
||||
|> User.Query.build()
|
||||
|> where([u], not is_nil(u.email))
|
||||
|> Repo.all()
|
||||
|> Enum.map(&Pleroma.Emails.NewUsersDigestEmail.new_users(&1, users_and_statuses))
|
||||
|> Enum.each(&Pleroma.Emails.Mailer.deliver/1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue