2020-08-02 13:54:59 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-08-02 13:54:59 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.User.WelcomeChatMessageTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
|
|
|
|
alias Pleroma.User.WelcomeChatMessage
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
setup do: clear_config([:welcome])
|
|
|
|
|
|
|
|
describe "post_message/1" do
|
|
|
|
test "send a chat welcome message" do
|
2020-08-03 18:13:43 +00:00
|
|
|
welcome_user = insert(:user, name: "mewmew")
|
|
|
|
user = insert(:user)
|
2020-08-02 13:54:59 +00:00
|
|
|
|
2021-01-26 17:58:43 +00:00
|
|
|
clear_config([:welcome, :chat_message, :enabled], true)
|
|
|
|
clear_config([:welcome, :chat_message, :sender_nickname], welcome_user.nickname)
|
2020-08-02 13:54:59 +00:00
|
|
|
|
2021-01-26 17:58:43 +00:00
|
|
|
clear_config(
|
2020-08-02 13:54:59 +00:00
|
|
|
[:welcome, :chat_message, :message],
|
2020-08-03 18:13:43 +00:00
|
|
|
"Hello, welcome to Blob/Cat!"
|
2020-08-02 13:54:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
{:ok, %Pleroma.Activity{} = activity} = WelcomeChatMessage.post_message(user)
|
|
|
|
|
|
|
|
assert user.ap_id in activity.recipients
|
2021-01-04 12:38:31 +00:00
|
|
|
assert Pleroma.Object.normalize(activity, fetch: false).data["type"] == "ChatMessage"
|
|
|
|
|
|
|
|
assert Pleroma.Object.normalize(activity, fetch: false).data["content"] ==
|
|
|
|
"Hello, welcome to Blob/Cat!"
|
2020-08-02 13:54:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|