From: lain Date: Mon, 28 Oct 2019 07:27:45 +0000 (+0000) Subject: Merge branch 'refactor/following-relationships' into 'develop' X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=248020075982a18534aebec3ff63eee0ae6185f4;p=akkoma Merge branch 'refactor/following-relationships' into 'develop' Move following relationships to a separate table Closes #1233 See merge request pleroma/pleroma!1814 --- 248020075982a18534aebec3ff63eee0ae6185f4 diff --cc lib/pleroma/user.ex index 5d3f55721,03c02a47f..40171620e --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@@ -216,14 -216,56 +216,8 @@@ defmodule Pleroma.User d from(u in query, where: u.deactivated != ^true) end - def following_count(%User{following: []}), do: 0 - - def following_count(%User{} = user) do - user - |> get_friends_query() - |> Repo.aggregate(:count, :id) - end + defdelegate following_count(user), to: FollowingRelationship - @info_fields [ - :banner, - :background, - :source_data, - :note_count, - :follower_count, - :following_count, - :locked, - :confirmation_pending, - :password_reset_pending, - :confirmation_token, - :default_scope, - :blocks, - :domain_blocks, - :mutes, - :muted_reblogs, - :muted_notifications, - :subscribers, - :deactivated, - :no_rich_text, - :ap_enabled, - :is_moderator, - :is_admin, - :show_role, - :settings, - :magic_key, - :uri, - :hide_followers_count, - :hide_follows_count, - :hide_followers, - :hide_follows, - :hide_favorites, - :unread_conversation_count, - :pinned_activities, - :email_notifications, - :mascot, - :emoji, - :pleroma_settings_store, - :fields, - :raw_fields, - :discoverable, - :invisible, - :skip_thread_containment, - :notification_settings - ] - - def info_fields, do: @info_fields - defp truncate_fields_param(params) do if Map.has_key?(params, :fields) do Map.put(params, :fields, Enum.map(params[:fields], &truncate_field/1)) @@@ -993,20 -990,8 +942,8 @@@ end end - def increment_unread_conversation_count(_, _), do: :noop + def increment_unread_conversation_count(_, user), do: {:ok, user} - def remove_duplicated_following(%User{following: following} = user) do - uniq_following = Enum.uniq(following) - - if length(following) == length(uniq_following) do - {:ok, user} - else - user - |> update_changeset(%{following: uniq_following}) - |> update_and_set_cache() - end - end - @spec get_users_from_set([String.t()], boolean()) :: [User.t()] def get_users_from_set(ap_ids, local_only \\ true) do criteria = %{ap_id: ap_ids, deactivated: false}