X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fobject.ex;h=e678fd415465850fb452bcd4075ae612bff95f9f;hb=93f64aba78f130cced2fa30dd3475e5c446be9d6;hp=20aba4c15e36ec7820a17e58ce50acfa93b9471f;hpb=32d1e048178a94017c9d8cca79b28272fa6da9f4;p=akkoma
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
index 20aba4c15..e678fd415 100644
--- a/lib/pleroma/object.ex
+++ b/lib/pleroma/object.ex
@@ -1,10 +1,13 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Object do
use Ecto.Schema
+ import Ecto.Query
+ import Ecto.Changeset
+
alias Pleroma.Activity
alias Pleroma.Object
alias Pleroma.Object.Fetcher
@@ -12,9 +15,6 @@ defmodule Pleroma.Object do
alias Pleroma.Repo
alias Pleroma.User
- import Ecto.Query
- import Ecto.Changeset
-
require Logger
@type t() :: %__MODULE__{}
@@ -261,7 +261,7 @@ defmodule Pleroma.Object do
end
end
- def increase_vote_count(ap_id, name) do
+ def increase_vote_count(ap_id, name, actor) do
with %Object{} = object <- Object.normalize(ap_id),
"Question" <- object.data["type"] do
multiple = Map.has_key?(object.data, "anyOf")
@@ -276,12 +276,15 @@ defmodule Pleroma.Object do
option
end)
+ voters = [actor | object.data["voters"] || []] |> Enum.uniq()
+
data =
if multiple do
Map.put(object.data, "anyOf", options)
else
Map.put(object.data, "oneOf", options)
end
+ |> Map.put("voters", voters)
object
|> Object.change(%{data: data})