forked from AkkomaGang/akkoma
ActivityPub: Small refactor.
This commit is contained in:
parent
f316882464
commit
4cf1007a7d
1 changed files with 11 additions and 12 deletions
|
@ -129,19 +129,18 @@ def increase_poll_votes_if_vote(_create_data), do: :noop
|
||||||
# TODO rewrite in with style
|
# TODO rewrite in with style
|
||||||
@spec persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
|
@spec persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
|
||||||
def persist(object, meta) do
|
def persist(object, meta) do
|
||||||
local = Keyword.fetch!(meta, :local)
|
with local <- Keyword.fetch!(meta, :local),
|
||||||
{recipients, _, _} = get_recipients(object)
|
{recipients, _, _} <- get_recipients(object),
|
||||||
|
{:ok, activity} <-
|
||||||
{:ok, activity} =
|
|
||||||
Repo.insert(%Activity{
|
Repo.insert(%Activity{
|
||||||
data: object,
|
data: object,
|
||||||
local: local,
|
local: local,
|
||||||
recipients: recipients,
|
recipients: recipients,
|
||||||
actor: object["actor"]
|
actor: object["actor"]
|
||||||
})
|
}) do
|
||||||
|
|
||||||
{:ok, activity, meta}
|
{:ok, activity, meta}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
|
def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
|
||||||
with nil <- Activity.normalize(map),
|
with nil <- Activity.normalize(map),
|
||||||
|
|
Loading…
Reference in a new issue