Fix clippy with one/five lines
[akkoma] / lib / pleroma / activity.ex
index be04363aab20b7c11db4534ed8844e083a599867..d907791b57f4fda10529ea0597db39edff73a5c2 100644 (file)
@@ -1,7 +1,14 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Activity do
   use Ecto.Schema
   alias Pleroma.{Repo, Activity, Notification}
-  import Ecto.{Query, Changeset}
+  import Ecto.Query
+
+  @type t :: %__MODULE__{}
+  @primary_key {:id, Pleroma.FlakeId, autogenerate: true}
 
   # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19
   @mastodon_notification_types %{
@@ -30,6 +37,10 @@ defmodule Pleroma.Activity do
     )
   end
 
+  def get_by_id(id) do
+    Repo.get(Activity, id)
+  end
+
   # TODO:
   # Go through these and fix them everywhere.
   # Wrong name, only returns create activities
@@ -103,25 +114,4 @@ defmodule Pleroma.Activity do
   end
 
   def mastodon_notification_type(%Activity{}), do: nil
-
-  def get_tombstone(%Activity{data: data}, deleted \\ DateTime.utc_now()) do
-    %{
-      id: data["id"],
-      context: data["context"],
-      type: "Tombstone",
-      published: data["published"],
-      deleted: deleted
-    }
-  end
-
-  def swap_data_with_tombstone(activity) do
-    with tombstone = get_tombstone(activity),
-         Notification.clear(activity),
-         {:ok, changed_activity} =
-           activity
-           |> change(%{data: tombstone})
-           |> Repo.update() do
-      {:ok, changed_activity}
-    end
-  end
 end