Merge develop
[akkoma] / lib / pleroma / bookmark.ex
index c5c3e078b67cfd055b25b8d0b5a5894eb382db11..d976f949c4f549cae5be55bf43eb05470cab70f9 100644 (file)
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Bookmark do
   use Ecto.Schema
 
@@ -41,6 +45,13 @@ defmodule Pleroma.Bookmark do
     |> preload([b, a], activity: a)
   end
 
+  def get(user_id, activity_id) do
+    Bookmark
+    |> where(user_id: ^user_id)
+    |> where(activity_id: ^activity_id)
+    |> Repo.one()
+  end
+
   @spec destroy(FlakeId.t(), FlakeId.t()) :: {:ok, Bookmark.t()} | {:error, Changeset.t()}
   def destroy(user_id, activity_id) do
     from(b in Bookmark,