logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 21716aa594064d5f4f4a91a8b40a679775709e1d
parent a43b899e94c499a9b5cb1a072fe4b96f0f02696f
Author: lain <lain@soykaf.club>
Date:   Tue,  5 Nov 2019 12:02:45 +0000

Merge branch 'release/1.1.4' into 'stable'

Release/1.1.4 - user.info fix plus NOT NULL for user.info

See merge request pleroma/pleroma!1927

Diffstat:

MCHANGELOG.md6++++++
Mlib/pleroma/web/streamer/worker.ex2+-
Mmix.exs2+-
Mpriv/repo/migrations/20190414125034_migrate_old_bookmarks.exs6+++---
Apriv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs17+++++++++++++++++
Mpriv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs2+-
Apriv/repo/migrations/20191104143558_fix_null_muted_notification_fields.exs7+++++++
Mtest/support/builders/user_builder.ex3++-
Mtest/web/streamer/streamer_test.exs18++++++++++++++++++
9 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [1.1.4] - 2019-11-01 +### Fixed +- Added a migration that fills up empty user.info fields to prevent breakage after previous unsafe migrations. +- Failure to migrate from pre-1.0.0 versions +- Mastodon API: Notification stream not including follow notifications + ## [1.1.3] - 2019-10-25 ### Fixed - Blocked users showing up in notifications collapsed as if they were muted diff --git a/lib/pleroma/web/streamer/worker.ex b/lib/pleroma/web/streamer/worker.ex @@ -136,7 +136,7 @@ defmodule Pleroma.Web.Streamer.Worker do recipients = MapSet.new(item.recipients) domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.info.domain_blocks) - with parent when not is_nil(parent) <- Object.normalize(item), + with parent <- Object.normalize(item) || item, true <- Enum.all?([blocks, mutes, reblog_mutes], &(item.actor not in &1)), true <- Enum.all?([blocks, mutes], &(parent.data["actor"] not in &1)), true <- MapSet.disjoint?(recipients, recipient_blocks), diff --git a/mix.exs b/mix.exs @@ -4,7 +4,7 @@ defmodule Pleroma.Mixfile do def project do [ app: :pleroma, - version: version("1.1.3"), + version: version("1.1.4"), elixir: "~> 1.7", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), diff --git a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs @@ -8,10 +8,10 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do def up do query = - from(u in User, + from(u in "users", where: u.local == true, - where: fragment("array_length(bookmarks, 1)") > 0, - select: %{id: u.id, bookmarks: fragment("bookmarks")} + where: fragment("array_length(?, 1)", u.bookmarks) > 0, + select: %{id: u.id, bookmarks: u.bookmarks} ) Repo.stream(query) diff --git a/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs b/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs @@ -0,0 +1,17 @@ +defmodule Pleroma.Repo.Migrations.FixAndSecureUserInfoField do + use Ecto.Migration + + def up do + execute("UPDATE users SET info = '{}'::jsonb WHERE info IS NULL") + + execute("ALTER TABLE users + ALTER COLUMN info SET NOT NULL + ") + end + + def down do + execute("ALTER TABLE users + ALTER COLUMN info DROP NOT NULL + ") + end +end diff --git a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs @@ -3,6 +3,6 @@ defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do alias Pleroma.User def change do - execute("update users set info = safe_jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true") + execute("update users set info = safe_jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true and info->'mutes' is not null") end end diff --git a/priv/repo/migrations/20191104143558_fix_null_muted_notification_fields.exs b/priv/repo/migrations/20191104143558_fix_null_muted_notification_fields.exs @@ -0,0 +1,7 @@ +defmodule Pleroma.Repo.Migrations.FixNullMutedNotificationFields do + use Ecto.Migration + + def change do + execute("update users set info = safe_jsonb_set(info, '{muted_notifications}', '[]'::jsonb, true) where local = true and info->'muted_notifications' = 'null'::jsonb") + end +end diff --git a/test/support/builders/user_builder.ex b/test/support/builders/user_builder.ex @@ -10,7 +10,8 @@ defmodule Pleroma.Builders.UserBuilder do password_hash: Comeonin.Pbkdf2.hashpwsalt("test"), bio: "A tester.", ap_id: "some id", - last_digest_emailed_at: NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + last_digest_emailed_at: NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second), + info: %{} } Map.merge(user, data) diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs @@ -110,6 +110,24 @@ defmodule Pleroma.Web.StreamerTest do Streamer.stream("user:notification", notif) Task.await(task) end + + test "it sends follow activities to the 'user:notification' stream", %{ + user: user + } do + user2 = insert(:user) + task = Task.async(fn -> assert_receive {:text, _}, 4_000 end) + + Streamer.add_socket( + "user:notification", + %{transport_pid: task.pid, assigns: %{user: user}} + ) + + {:ok, _follower, _followed, _activity} = CommonAPI.follow(user2, user) + + # We don't directly pipe the notification to the streamer as it's already + # generated as a side effect of CommonAPI.follow(). + Task.await(task) + end end test "it sends to public" do