diff options
author | Alex S <alex.strizhakov@gmail.com> | 2019-07-10 16:01:32 +0300 |
---|---|---|
committer | Alex S <alex.strizhakov@gmail.com> | 2019-07-10 17:42:18 +0300 |
commit | f8786fa6f27b1934b48b69fce5d285ebddefda92 (patch) | |
tree | 3a8cc24f2688453aac11424f5bd982f526e19e29 /lib | |
parent | b972b972e00d1528f77fe726e066f35cf1323cb7 (diff) | |
download | pleroma-f8786fa6f27b1934b48b69fce5d285ebddefda92.tar.gz |
adding following_address field to user
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/user.ex | 30 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 1 |
2 files changed, 23 insertions, 8 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 034c414bf..81efb4f13 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -52,6 +52,7 @@ defmodule Pleroma.User do field(:avatar, :map) field(:local, :boolean, default: true) field(:follower_address, :string) + field(:following_address, :string) field(:search_rank, :float, virtual: true) field(:search_type, :integer, virtual: true) field(:tags, {:array, :string}, default: []) @@ -162,9 +163,10 @@ defmodule Pleroma.User do if changes.valid? do case info_cng.changes[:source_data] do - %{"followers" => followers} -> + %{"followers" => followers, "following" => following} -> changes |> put_change(:follower_address, followers) + |> put_change(:following_address, following) _ -> followers = User.ap_followers(%User{nickname: changes.changes[:nickname]}) @@ -196,7 +198,14 @@ defmodule Pleroma.User do |> User.Info.user_upgrade(params[:info]) struct - |> cast(params, [:bio, :name, :follower_address, :avatar, :last_refreshed_at]) + |> cast(params, [ + :bio, + :name, + :follower_address, + :following_address, + :avatar, + :last_refreshed_at + ]) |> unique_constraint(:nickname) |> validate_format(:nickname, local_nickname_regex()) |> validate_length(:bio, max: 5000) @@ -1039,15 +1048,20 @@ defmodule Pleroma.User do end end + @spec external_users_query() :: Ecto.Query.t() + def external_users_query do + User.Query.build(%{ + external: true, + active: true, + order_by: :id + }) + end + @spec external_users(keyword()) :: [User.t()] def external_users(opts \\ []) do query = - User.Query.build(%{ - external: true, - active: true, - order_by: :id, - select: [:id, :ap_id, :info] - }) + external_users_query() + |> select([u], struct(u, [:id, :ap_id, :info])) query = if opts[:max_id], diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 41b55bbab..a3174a787 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -994,6 +994,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do avatar: avatar, name: data["name"], follower_address: data["followers"], + following_address: data["following"], bio: data["summary"] } |