From 7701a4c84191a445e0b62e8a241e8af86f86e16a Mon Sep 17 00:00:00 2001 From: Sachin Joshi Date: Mon, 13 May 2019 23:50:33 +0545 Subject: [PATCH] Make irreversible field default to false in filters --- CHANGELOG.md | 1 + lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 2 +- ...20190513175809_change_hide_column_in_filter_table.exs | 9 +++++++++ test/web/mastodon_api/mastodon_api_controller_test.exs | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index b9c9538b0..76e6f6b39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,6 +92,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mastodon API: Handling of `reblogs` in `/api/v1/accounts/:id/follow` - Mastodon API: Correct `reblogged`, `favourited`, and `bookmarked` values in the reblog status JSON - Mastodon API: Exposing default scope of the user to anyone +- Mastodon API: Make `irreversible` field default to `false` [`POST /api/v1/filters`] ## [0.9.9999] - 2019-04-05 ### Security diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 956736780..fd595031d 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1536,7 +1536,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do user_id: user.id, phrase: phrase, context: context, - hide: Map.get(params, "irreversible", nil), + hide: Map.get(params, "irreversible", false), whole_word: Map.get(params, "boolean", true) # expires_at } diff --git a/priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs b/priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs new file mode 100644 index 000000000..2ffb88cc9 --- /dev/null +++ b/priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs @@ -0,0 +1,9 @@ +defmodule Pleroma.Repo.Migrations.ChangeHideColumnInFilterTable do + use Ecto.Migration + + def change do + alter table(:filters) do + modify :hide, :boolean, default: false + end + end +end diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 505e45010..537cd98d5 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -572,6 +572,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert response = json_response(conn, 200) assert response["phrase"] == filter.phrase assert response["context"] == filter.context + assert response["irreversible"] == false assert response["id"] != nil assert response["id"] != "" end