summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormarcin mikołajczak <git@mkljczk.pl>2024-04-06 10:54:59 +0200
committermarcin mikołajczak <git@mkljczk.pl>2024-04-06 11:45:19 +0200
commitccc3ac241f5b7c88b36efe60a4f9e5d791d2d49a (patch)
tree8f463989ca84ce2d9af9ff1fb385c35a247404d1 /lib
parent01a5f839c58d89be802e162280bd02c577bdec89 (diff)
downloadpleroma-ccc3ac241f5b7c88b36efe60a4f9e5d791d2d49a.tar.gz
pleroma-ccc3ac241f5b7c88b36efe60a4f9e5d791d2d49a.zip
Add hint to rules
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/rule.ex3
-rw-r--r--lib/pleroma/web/admin_api/views/rule_view.ex3
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/report_operation.ex3
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/rule_operation.ex9
-rw-r--r--lib/pleroma/web/api_spec/operations/instance_operation.ex3
-rw-r--r--lib/pleroma/web/mastodon_api/views/instance_view.ex3
6 files changed, 16 insertions, 8 deletions
diff --git a/lib/pleroma/rule.ex b/lib/pleroma/rule.ex
index c8e3470c7..3ba413214 100644
--- a/lib/pleroma/rule.ex
+++ b/lib/pleroma/rule.ex
@@ -14,13 +14,14 @@ defmodule Pleroma.Rule do
schema "rules" do
field(:priority, :integer, default: 0)
field(:text, :string)
+ field(:hint, :string)
timestamps()
end
def changeset(%Rule{} = rule, params \\ %{}) do
rule
- |> cast(params, [:priority, :text])
+ |> cast(params, [:priority, :text, :hint])
|> validate_required([:text])
end
diff --git a/lib/pleroma/web/admin_api/views/rule_view.ex b/lib/pleroma/web/admin_api/views/rule_view.ex
index abfdd593f..606443f05 100644
--- a/lib/pleroma/web/admin_api/views/rule_view.ex
+++ b/lib/pleroma/web/admin_api/views/rule_view.ex
@@ -15,7 +15,8 @@ defmodule Pleroma.Web.AdminAPI.RuleView do
%{
id: to_string(rule.id),
priority: rule.priority,
- text: rule.text
+ text: rule.text,
+ hint: rule.hint
}
end
end
diff --git a/lib/pleroma/web/api_spec/operations/admin/report_operation.ex b/lib/pleroma/web/api_spec/operations/admin/report_operation.ex
index 971231f4d..25a604beb 100644
--- a/lib/pleroma/web/api_spec/operations/admin/report_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/admin/report_operation.ex
@@ -182,7 +182,8 @@ defmodule Pleroma.Web.ApiSpec.Admin.ReportOperation do
type: :object,
properties: %{
id: %Schema{type: :string},
- text: %Schema{type: :string}
+ text: %Schema{type: :string},
+ hint: %Schema{type: :string, nullable: true}
}
}
}
diff --git a/lib/pleroma/web/api_spec/operations/admin/rule_operation.ex b/lib/pleroma/web/api_spec/operations/admin/rule_operation.ex
index 2360880e4..c3a3ecc7c 100644
--- a/lib/pleroma/web/api_spec/operations/admin/rule_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/admin/rule_operation.ex
@@ -84,7 +84,8 @@ defmodule Pleroma.Web.ApiSpec.Admin.RuleOperation do
required: [:text],
properties: %{
priority: %Schema{type: :integer},
- text: %Schema{type: :string}
+ text: %Schema{type: :string},
+ hint: %Schema{type: :string}
}
}
end
@@ -94,7 +95,8 @@ defmodule Pleroma.Web.ApiSpec.Admin.RuleOperation do
type: :object,
properties: %{
priority: %Schema{type: :integer},
- text: %Schema{type: :string}
+ text: %Schema{type: :string},
+ hint: %Schema{type: :string}
}
}
end
@@ -105,7 +107,8 @@ defmodule Pleroma.Web.ApiSpec.Admin.RuleOperation do
properties: %{
id: %Schema{type: :string},
priority: %Schema{type: :integer},
- text: %Schema{type: :string}
+ text: %Schema{type: :string},
+ hint: %Schema{type: :string, nullable: true}
}
}
end
diff --git a/lib/pleroma/web/api_spec/operations/instance_operation.ex b/lib/pleroma/web/api_spec/operations/instance_operation.ex
index faf79c2ea..4cd457ae7 100644
--- a/lib/pleroma/web/api_spec/operations/instance_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/instance_operation.ex
@@ -364,7 +364,8 @@ defmodule Pleroma.Web.ApiSpec.InstanceOperation do
type: :object,
properties: %{
id: %Schema{type: :string},
- text: %Schema{type: :string}
+ text: %Schema{type: :string},
+ hint: %Schema{type: :string}
}
}
}
diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex
index 6a3d445c5..d00f1bd9e 100644
--- a/lib/pleroma/web/mastodon_api/views/instance_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex
@@ -85,7 +85,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
def render("rule.json", %{rule: rule}) do
%{
id: to_string(rule.id),
- text: rule.text
+ text: rule.text,
+ hint: rule.hint || ""
}
end