X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fworkers%2Fscheduled_activity_worker.ex;h=8905f4ad000a3b7be3e4651c80e3460e78a1a8fc;hb=a3bb2e5474ee068bf375b24df8906e51654c9699;hp=5109d7f759aa77bd33a61fcc2088ba6905678d8d;hpb=54c9db38c8035ecc115e136a09a3d991e426959a;p=akkoma
diff --git a/lib/pleroma/workers/scheduled_activity_worker.ex b/lib/pleroma/workers/scheduled_activity_worker.ex
index 5109d7f75..8905f4ad0 100644
--- a/lib/pleroma/workers/scheduled_activity_worker.ex
+++ b/lib/pleroma/workers/scheduled_activity_worker.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.ScheduledActivityWorker do
@@ -29,12 +29,12 @@ defmodule Pleroma.Workers.ScheduledActivityWorker do
end
end
- defp post_activity(%ScheduledActivity{} = scheduled_activity) do
- try do
- {:ok, scheduled_activity} = ScheduledActivity.delete(scheduled_activity)
- %User{} = user = User.get_cached_by_id(scheduled_activity.user_id)
- {:ok, _result} = CommonAPI.post(user, scheduled_activity.params)
- rescue
+ defp post_activity(%ScheduledActivity{user_id: user_id, params: params} = scheduled_activity) do
+ with {:delete, {:ok, _}} <- {:delete, ScheduledActivity.delete(scheduled_activity)},
+ {:user, %User{} = user} <- {:user, User.get_cached_by_id(user_id)},
+ {:post, {:ok, _}} <- {:post, CommonAPI.post(user, params)} do
+ :ok
+ else
error ->
Logger.error(
"#{__MODULE__} Couldn't create a status from the scheduled activity: #{inspect(error)}"