diff options
Diffstat (limited to 'lib/pleroma/user.ex')
-rw-r--r-- | lib/pleroma/user.ex | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 712d3b1d9..18699f0c8 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1482,15 +1482,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 + DateTime.utc_now() + |> DateTime.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 |