From 5d753e1c7cb1b26ad224255c31b0b64ad917ebaa Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 29 Nov 2018 06:52:54 +0000 Subject: [PATCH] activity: add helpers for updating activities in the database --- lib/pleroma/activity.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 34d0a34b8..e3aa4eb97 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -1,7 +1,7 @@ defmodule Pleroma.Activity do use Ecto.Schema alias Pleroma.{Repo, Activity, Notification, Object} - import Ecto.Query + import Ecto.{Query, Changeset} schema "activities" do field(:data, :map) @@ -22,6 +22,13 @@ defmodule Pleroma.Activity do ) end + def change(struct, params \\ %{}) do + struct + |> cast(params, [:data]) + |> validate_required([:data]) + |> unique_constraint(:ap_id, name: :activities_unique_apid_index) + end + # TODO: # Go through these and fix them everywhere. # Wrong name, only returns create activities -- 2.45.2