summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-11-05 12:02:45 +0000
committerlain <lain@soykaf.club>2019-11-05 12:02:45 +0000
commit21716aa594064d5f4f4a91a8b40a679775709e1d (patch)
tree660f575029e4eaf8cf5577049ab67ed1902a04a2
parenta43b899e94c499a9b5cb1a072fe4b96f0f02696f (diff)
parentb7de4ad0828078ed5aa03d243319855ce3eb95f8 (diff)
Merge branch 'release/1.1.4' into 'stable'v1.1.4
Release/1.1.4 - user.info fix plus NOT NULL for user.info See merge request pleroma/pleroma!1927
-rw-r--r--CHANGELOG.md6
-rw-r--r--lib/pleroma/web/streamer/worker.ex2
-rw-r--r--mix.exs2
-rw-r--r--priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs6
-rw-r--r--priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs17
-rw-r--r--priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs2
-rw-r--r--priv/repo/migrations/20191104143558_fix_null_muted_notification_fields.exs7
-rw-r--r--test/support/builders/user_builder.ex3
-rw-r--r--test/web/streamer/streamer_test.exs18
9 files changed, 56 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e078d422..4f681704c 100644
--- 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
index 0ea224874..da7a5a6f2 100644
--- 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
index fde6216d2..2f7ac0e80 100644
--- 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
index ce4590954..c547d2642 100644
--- 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
new file mode 100644
index 000000000..9602a8c41
--- /dev/null
+++ 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
index a3c5b52de..c0d6b3a87 100644
--- 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
new file mode 100644
index 000000000..e17e75983
--- /dev/null
+++ 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
index 6da16f71a..4bdaddc4a 100644
--- 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
index 313567bfd..601f6df49 100644
--- 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