2020-07-21 23:58:06 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2022-02-25 23:11:42 -07:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-07-21 23:58:06 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.User.WelcomeMessageTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
|
|
|
|
alias Pleroma.User.WelcomeMessage
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
setup do: clear_config([:welcome])
|
|
|
|
|
|
|
|
describe "post_message/1" do
|
|
|
|
test "send a direct welcome message" do
|
|
|
|
welcome_user = insert(:user)
|
|
|
|
user = insert(:user, name: "Jimm")
|
|
|
|
|
2021-01-26 10:58:43 -07:00
|
|
|
clear_config([:welcome, :direct_message, :enabled], true)
|
|
|
|
clear_config([:welcome, :direct_message, :sender_nickname], welcome_user.nickname)
|
2020-07-21 23:58:06 -06:00
|
|
|
|
2021-01-26 10:58:43 -07:00
|
|
|
clear_config(
|
2020-07-21 23:58:06 -06:00
|
|
|
[:welcome, :direct_message, :message],
|
|
|
|
"Hello. Welcome to Pleroma"
|
|
|
|
)
|
|
|
|
|
|
|
|
{:ok, %Pleroma.Activity{} = activity} = WelcomeMessage.post_message(user)
|
|
|
|
assert user.ap_id in activity.recipients
|
|
|
|
assert activity.data["directMessage"] == true
|
2021-01-04 05:38:31 -07:00
|
|
|
|
|
|
|
assert Pleroma.Object.normalize(activity, fetch: false).data["content"] =~
|
|
|
|
"Hello. Welcome to Pleroma"
|
2020-07-21 23:58:06 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|