Add safe dm mode option.
See merge request pleroma/pleroma!958
# General application configuration
config :pleroma, ecto_repos: [Pleroma.Repo]
-config :pleroma, Pleroma.Repo, types: Pleroma.PostgresTypes
-
config :pleroma, Pleroma.Captcha,
enabled: false,
seconds_valid: 60,
no_attachment_links: false,
welcome_user_nickname: nil,
welcome_message: nil,
- max_report_comment_size: 1000
+ max_report_comment_size: 1000,
+ safe_dm_mentions: false
config :pleroma, :markup,
# XXX - unfortunately, inline images must be enabled by default right now, because
config :pleroma, :chat, enabled: true
-config :ecto, json_library: Jason
-
config :phoenix, :format_encoders, json: Jason
config :pleroma, :gopher,
* `no_attachment_links`: Set to true to disable automatically adding attachment link text to statuses
* `welcome_message`: A message that will be send to a newly registered users as a direct message.
* `welcome_user_nickname`: The nickname of the local user that sends the welcome message.
- * `max_report_size`: The maximum size of the report comment (Default: `1000`)
+ * `max_report_comment_size`: The maximum size of the report comment (Default: `1000`)
+ * `safe_dm_mentions`: If set to true, only mentions at the beginning of a post will be used to address people in direct messages. This is to prevent accidental mentioning of people when talking about them (e.g. "@friend hey i really don't like @enemy"). (Default: `false`)
## :logger
* `backends`: `:console` is used to send logs to stdout, `{ExSyslogger, :ex_syslogger}` to log to syslog
* `enabled`: Enables the gopher interface
* `ip`: IP address to bind to
* `port`: Port to bind to
+* `dstport`: Port advertised in urls (optional, defaults to `port`)
## :activitypub
* ``accept_blocks``: Whether to accept incoming block activities from other instances
def make_content_html(
status,
attachments,
- data
+ data,
+ visibility
) do
no_attachment_links =
data
content_type = get_content_type(data["content_type"])
+ options =
+ if visibility == "direct" && Config.get([:instance, :safe_dm_mentions]) do
+ [safe_mention: true]
+ else
+ []
+ end
+
status
- |> format_input(content_type)
+ |> format_input(content_type, options)
|> maybe_add_attachments(attachments, no_attachment_links)
|> maybe_add_nsfw_tag(data)
end
end
def get_report_statuses(_, _), do: {:ok, nil}
+
+ # DEPRECATED mostly, context objects are now created at insertion time.
+ def context_to_conversation_id(context) do
+ with %Object{id: id} <- Object.get_cached_by_ap_id(context) do
+ id
+ else
+ _e ->
+ changeset = Object.context_mapping(context)
+
+ case Repo.insert(changeset) do
+ {:ok, %{id: id}} ->
+ id
+
+ # This should be solved by an upsert, but it seems ecto
+ # has problems accessing the constraint inside the jsonb.
+ {:error, _} ->
+ Object.get_cached_by_ap_id(context).id
+ end
+ end
+ end
+
+ def conversation_id_to_context(id) do
+ with %Object{data: %{"id" => context}} <- Repo.get(Object, id) do
+ context
+ else
+ _e ->
+ {:error, "No such conversation"}
+ end
+ end
end