projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add documentation for the emoji api endpoints
[akkoma]
/
lib
/
pleroma
/
delivery.ex
diff --git
a/lib/pleroma/delivery.ex
b/lib/pleroma/delivery.ex
index 2e7c019fabcd11607f262b9d86705a86c617681e..29a1e5a77c7ae14b78116fa0b0433858560ca828 100644
(file)
--- a/
lib/pleroma/delivery.ex
+++ b/
lib/pleroma/delivery.ex
@@
-7,9
+7,9
@@
defmodule Pleroma.Delivery do
alias Pleroma.Delivery
alias Pleroma.FlakeId
alias Pleroma.Delivery
alias Pleroma.FlakeId
- alias Pleroma.User
- alias Pleroma.Repo
alias Pleroma.Object
alias Pleroma.Object
+ alias Pleroma.Repo
+ alias Pleroma.User
alias Pleroma.User
import Ecto.Changeset
alias Pleroma.User
import Ecto.Changeset
@@
-23,6
+23,7
@@
defmodule Pleroma.Delivery do
def changeset(delivery, params \\ %{}) do
delivery
|> cast(params, [:user_id, :object_id])
def changeset(delivery, params \\ %{}) do
delivery
|> cast(params, [:user_id, :object_id])
+ |> validate_required([:user_id, :object_id])
|> foreign_key_constraint(:object_id)
|> foreign_key_constraint(:user_id)
|> unique_constraint(:user_id, name: :deliveries_user_id_object_id_index)
|> foreign_key_constraint(:object_id)
|> foreign_key_constraint(:user_id)
|> unique_constraint(:user_id, name: :deliveries_user_id_object_id_index)
@@
-31,7
+32,7
@@
defmodule Pleroma.Delivery do
def create(object_id, user_id) do
%Delivery{}
|> changeset(%{user_id: user_id, object_id: object_id})
def create(object_id, user_id) do
%Delivery{}
|> changeset(%{user_id: user_id, object_id: object_id})
- |> Repo.insert()
+ |> Repo.insert(
on_conflict: :nothing
)
end
def get(object_id, user_id) do
end
def get(object_id, user_id) do
@@
-39,13
+40,6
@@
defmodule Pleroma.Delivery do
|> Repo.one()
end
|> Repo.one()
end
- def get_or_create(object_id, user_id) do
- case get(object_id, user_id) do
- %Delivery{} = delivery -> {:ok, delivery}
- nil -> create(object_id, user_id)
- end
- end
-
# A hack because user delete activities have a fake id for whatever reason
# TODO: Get rid of this
def delete_all_by_object_id("pleroma:fake_object_id"), do: {0, []}
# A hack because user delete activities have a fake id for whatever reason
# TODO: Get rid of this
def delete_all_by_object_id("pleroma:fake_object_id"), do: {0, []}
@@
-54,9
+48,4
@@
defmodule Pleroma.Delivery do
from(d in Delivery, where: d.object_id == ^object_id)
|> Repo.delete_all()
end
from(d in Delivery, where: d.object_id == ^object_id)
|> Repo.delete_all()
end
-
- def get_all_by_object_id(object_id) do
- from(d in Delivery, where: d.object_id == ^object_id)
- |> Repo.all()
- end
end
end