Store mutes expiration date
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
75f912c63f
commit
b0f83aea29
6 changed files with 73 additions and 13 deletions
|
|
@ -1461,15 +1461,28 @@ defmodule Pleroma.User do
|
|||
notifications? = Map.get(params, :notifications, true)
|
||||
expires_in = Map.get(params, :expires_in, 0)
|
||||
|
||||
with {:ok, user_mute} <- UserRelationship.create_mute(muter, mutee),
|
||||
expires_at =
|
||||
if expires_in > 0 do
|
||||
NaiveDateTime.utc_now()
|
||||
|> NaiveDateTime.add(expires_in)
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
with {:ok, user_mute} <- UserRelationship.create_mute(muter, mutee, expires_at),
|
||||
{:ok, user_notification_mute} <-
|
||||
(notifications? && UserRelationship.create_notification_mute(muter, mutee)) ||
|
||||
(notifications? &&
|
||||
UserRelationship.create_notification_mute(
|
||||
muter,
|
||||
mutee,
|
||||
expires_at
|
||||
)) ||
|
||||
{:ok, nil} do
|
||||
if expires_in > 0 do
|
||||
Pleroma.Workers.MuteExpireWorker.enqueue(
|
||||
"unmute_user",
|
||||
%{"muter_id" => muter.id, "mutee_id" => mutee.id},
|
||||
schedule_in: expires_in
|
||||
scheduled_at: expires_at
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue