logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

quote_to_link_tag_policy_test.exs (1979B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.ActivityPub.MRF.QuoteToLinkTagPolicyTest do
  5. alias Pleroma.Web.ActivityPub.MRF.QuoteToLinkTagPolicy
  6. use Pleroma.DataCase
  7. require Pleroma.Constants
  8. test "Add quote url to Link tag" do
  9. quote_url = "https://gleasonator.com/objects/1234"
  10. activity = %{
  11. "type" => "Create",
  12. "actor" => "https://gleasonator.com/users/alex",
  13. "object" => %{
  14. "type" => "Note",
  15. "content" => "Nice post",
  16. "quoteUrl" => quote_url
  17. }
  18. }
  19. {:ok, %{"object" => object}} = QuoteToLinkTagPolicy.filter(activity)
  20. assert object["tag"] == [
  21. %{
  22. "type" => "Link",
  23. "href" => quote_url,
  24. "mediaType" => Pleroma.Constants.activity_json_canonical_mime_type()
  25. }
  26. ]
  27. end
  28. test "Add quote url to Link tag, append to the end" do
  29. quote_url = "https://gleasonator.com/objects/1234"
  30. activity = %{
  31. "type" => "Create",
  32. "actor" => "https://gleasonator.com/users/alex",
  33. "object" => %{
  34. "type" => "Note",
  35. "content" => "Nice post",
  36. "quoteUrl" => quote_url,
  37. "tag" => [%{"type" => "Hashtag", "name" => "#foo"}]
  38. }
  39. }
  40. {:ok, %{"object" => object}} = QuoteToLinkTagPolicy.filter(activity)
  41. assert [_, tag] = object["tag"]
  42. assert tag == %{
  43. "type" => "Link",
  44. "href" => quote_url,
  45. "mediaType" => Pleroma.Constants.activity_json_canonical_mime_type()
  46. }
  47. end
  48. test "Bypass posts without quoteUrl" do
  49. activity = %{
  50. "type" => "Create",
  51. "actor" => "https://gleasonator.com/users/alex",
  52. "object" => %{
  53. "type" => "Note",
  54. "content" => "Nice post"
  55. }
  56. }
  57. assert {:ok, ^activity} = QuoteToLinkTagPolicy.filter(activity)
  58. end
  59. end