mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-02 14:44:13 +00:00
Merge branch 'bugfix/osada-mention' into 'develop'
fix osada mentions Closes #324 See merge request pleroma/pleroma!380
This commit is contained in:
commit
6098070234
|
@ -248,7 +248,12 @@ defmodule Pleroma.Formatter do
|
|||
subs =
|
||||
subs ++
|
||||
Enum.map(mentions, fn {match, %User{ap_id: ap_id, info: info}, uuid} ->
|
||||
ap_id = info["source_data"]["url"] || ap_id
|
||||
ap_id =
|
||||
if is_binary(info["source_data"]["url"]) do
|
||||
info["source_data"]["url"]
|
||||
else
|
||||
ap_id
|
||||
end
|
||||
|
||||
short_match = String.split(match, "@") |> tl() |> hd()
|
||||
|
||||
|
|
54
test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json
vendored
Normal file
54
test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1"
|
||||
],
|
||||
"type": "Person",
|
||||
"id": "https://osada.macgirvin.com/channel/mike",
|
||||
"preferredUsername": "mike",
|
||||
"name": "Mike Macgirvin (Osada)",
|
||||
"updated": "2018-08-29T03:09:11Z",
|
||||
"icon": {
|
||||
"type": "Image",
|
||||
"mediaType": "image/jpeg",
|
||||
"updated": "2018-08-29T03:10:13Z",
|
||||
"url": "https://osada.macgirvin.com/photo/profile/l/2",
|
||||
"height": 300,
|
||||
"width": 300
|
||||
},
|
||||
"url": [
|
||||
{
|
||||
"type": "Link",
|
||||
"mediaType": "text/html",
|
||||
"href": "https://osada.macgirvin.com/channel/mike"
|
||||
},
|
||||
{
|
||||
"type": "Link",
|
||||
"mediaType": "text/x-zot+json",
|
||||
"href": "https://osada.macgirvin.com/channel/mike"
|
||||
}
|
||||
],
|
||||
"inbox": "https://osada.macgirvin.com/inbox/mike",
|
||||
"outbox": "https://osada.macgirvin.com/outbox/mike",
|
||||
"followers": "https://osada.macgirvin.com/followers/mike",
|
||||
"following": "https://osada.macgirvin.com/following/mike",
|
||||
"endpoints": {
|
||||
"sharedInbox": "https://osada.macgirvin.com/inbox"
|
||||
},
|
||||
"publicKey": {
|
||||
"id": "https://osada.macgirvin.com/channel/mike/public_key_pem",
|
||||
"owner": "https://osada.macgirvin.com/channel/mike",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAskSyK2VwBNKbzZl9XNJk\nvxU5AAilmRArMmmKSzphdHaVBHakeafUfixvqNrQ/oX2srJvJKcghNmEMrJ6MJ7r\npeEndVOo7pcP4PwVjtnC06p3J711q5tBehqM25BfCLCrB2YqWF6c8zk3CPN3Na21\n8k5s4cO95N/rGN+Po0XFAX/HjKjlpgNpKRDrpxmXxTU8NZfAqeQGJ5oiMBZI9vVB\n+eU7t1L6F5/XWuUCeP4OMrG8oZX822AREba8rknS6DpkWGES0Rx2eNOyYTf6ue75\nI6Ek6rlO+da5wMWr+3BvYMq4JMIwTHzAO+ZqqJPFpzKSiVuAWb2DOX/MDFecVWJE\ntF/R60lONxe4e/00MPCoDdqkLKdwROsk1yGL7z4Zk6jOWFEhIcWy/d2Ya5CpPvS3\nu4wNN4jkYAjra+8TiloRELhV4gpcEk8nkyNwLXOhYm7zQ5sIc5rfXoIrFzALB86W\nG05Nnqg+77zZIaTZpD9qekYlaEt+0OVtt9TTIeTiudQ983l6mfKwZYymrzymH1dL\nVgxBRYo+Z53QOSLiSKELfTBZxEoP1pBw6RiOHXydmJ/39hGgc2YAY/5ADwW2F2yb\nJ7+gxG6bPJ3ikDLYcD4CB5iJQdnTcDsFt3jyHAT6wOCzFAYPbHUqtzHfUM30dZBn\nnJhQF8udPLcXLaj6GW75JacCAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"signature": {
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1"
|
||||
],
|
||||
"type": "RsaSignature2017",
|
||||
"nonce": "bd60167a764a936788d9538531284dfacc258daae0297bc34a83bce136dedb5d",
|
||||
"creator": "https://osada.macgirvin.com/channel/mike/public_key_pem",
|
||||
"created": "2018-10-17T07:16:28Z",
|
||||
"signatureValue": "WbfFVIPImkd3yNu6brz0CvZaeV242rwAbH0vy8DM4vfnXCxLr5Uv/Wj9gwP+tbooTxGaahAKBeqlGkQp8RLEo37LATrKMRLA/0V6DeeV+C5ORWR9B4WxyWiD3s/9Wf+KesFMtktNLAcMZ5PfnOS/xNYerhnpkp/gWPxtkglmLIWJv+w18A5zZ01JCxsO4QljHbhYaEUPHUfQ97abrkLECeam+FThVwdO6BFCtbjoNXHfzjpSZL/oKyBpi5/fpnqMqOLOQPs5WgBBZJvjEYYkQcoPTyxYI5NGpNbzIjGHPQNuACnOelH16A7L+q4swLWDIaEFeXQ2/5bmqVKZDZZ6usNP4QyTVszwd8jqo27qcDTNibXDUTsTdKpNQvM/3UncBuzuzmUV3FczhtGshIU1/pRVZiQycpVqPlGLvXhP/yZCe+1siyqDd+3uMaS2vkHTObSl5r+VYof+c+TcjrZXHSWnQTg8/X3zkoBWosrQ93VZcwjzMxQoARYv6rphbOoTz7RPmGAXYUt3/PDWkqDlmQDwCpLNNkJo1EidyefZBdD9HXQpCBO0ZU0NHb0JmPvg/+zU0krxlv70bm3RHA/maBETVjroIWzt7EwQEg5pL2hVnvSBG+1wF3BtRVe77etkPOHxLnYYIcAMLlVKCcgDd89DPIziQyruvkx1busHI08="
|
||||
}
|
||||
}
|
53
test/fixtures/httpoison_mock/mike@osada.macgirvin.com.json
vendored
Normal file
53
test/fixtures/httpoison_mock/mike@osada.macgirvin.com.json
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"subject": "acct:mike@osada.macgirvin.com",
|
||||
"aliases": [
|
||||
"https://osada.macgirvin.com/channel/mike",
|
||||
"https://osada.macgirvin.com/~mike",
|
||||
"https://osada.macgirvin.com/@mike"
|
||||
],
|
||||
"properties": {
|
||||
"http://webfinger.net/ns/name": "Mike Macgirvin (Osada)",
|
||||
"http://xmlns.com/foaf/0.1/name": "Mike Macgirvin (Osada)",
|
||||
"https://w3id.org/security/v1#publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAskSyK2VwBNKbzZl9XNJk\nvxU5AAilmRArMmmKSzphdHaVBHakeafUfixvqNrQ/oX2srJvJKcghNmEMrJ6MJ7r\npeEndVOo7pcP4PwVjtnC06p3J711q5tBehqM25BfCLCrB2YqWF6c8zk3CPN3Na21\n8k5s4cO95N/rGN+Po0XFAX/HjKjlpgNpKRDrpxmXxTU8NZfAqeQGJ5oiMBZI9vVB\n+eU7t1L6F5/XWuUCeP4OMrG8oZX822AREba8rknS6DpkWGES0Rx2eNOyYTf6ue75\nI6Ek6rlO+da5wMWr+3BvYMq4JMIwTHzAO+ZqqJPFpzKSiVuAWb2DOX/MDFecVWJE\ntF/R60lONxe4e/00MPCoDdqkLKdwROsk1yGL7z4Zk6jOWFEhIcWy/d2Ya5CpPvS3\nu4wNN4jkYAjra+8TiloRELhV4gpcEk8nkyNwLXOhYm7zQ5sIc5rfXoIrFzALB86W\nG05Nnqg+77zZIaTZpD9qekYlaEt+0OVtt9TTIeTiudQ983l6mfKwZYymrzymH1dL\nVgxBRYo+Z53QOSLiSKELfTBZxEoP1pBw6RiOHXydmJ/39hGgc2YAY/5ADwW2F2yb\nJ7+gxG6bPJ3ikDLYcD4CB5iJQdnTcDsFt3jyHAT6wOCzFAYPbHUqtzHfUM30dZBn\nnJhQF8udPLcXLaj6GW75JacCAwEAAQ==\n-----END PUBLIC KEY-----\n",
|
||||
"http://purl.org/zot/federation": "zot6,activitypub"
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://webfinger.net/rel/avatar",
|
||||
"type": "image/jpeg",
|
||||
"href": "https://osada.macgirvin.com/photo/profile/l/2"
|
||||
},
|
||||
{
|
||||
"rel": "http://webfinger.net/rel/blog",
|
||||
"href": "https://osada.macgirvin.com/channel/mike"
|
||||
},
|
||||
{
|
||||
"rel": "http://openid.net/specs/connect/1.0/issuer",
|
||||
"href": "https://osada.macgirvin.com"
|
||||
},
|
||||
{
|
||||
"rel": "http://purl.org/zot/protocol/6.0",
|
||||
"type": "application/x-zot+json",
|
||||
"href": "https://osada.macgirvin.com/channel/mike"
|
||||
},
|
||||
{
|
||||
"rel": "http://purl.org/openwebauth/v1",
|
||||
"type": "application/x-zot+json",
|
||||
"href": "https://osada.macgirvin.com/owa"
|
||||
},
|
||||
{
|
||||
"rel": "http://ostatus.org/schema/1.0/subscribe",
|
||||
"template": "https://osada.macgirvin.com/follow?url={uri}"
|
||||
},
|
||||
{
|
||||
"rel": "self",
|
||||
"type": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"",
|
||||
"href": "https://osada.macgirvin.com/channel/mike"
|
||||
},
|
||||
{
|
||||
"rel": "self",
|
||||
"type": "application/activity+json",
|
||||
"href": "https://osada.macgirvin.com/channel/mike"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
defmodule Pleroma.FormatterTest do
|
||||
alias Pleroma.Formatter
|
||||
alias Pleroma.User
|
||||
use Pleroma.DataCase
|
||||
|
||||
import Pleroma.Factory
|
||||
|
@ -131,6 +132,24 @@ defmodule Pleroma.FormatterTest do
|
|||
assert expected_text == Formatter.finalize({subs, text})
|
||||
end
|
||||
|
||||
test "gives a replacement for user links when the user is using Osada" do
|
||||
mike = User.get_or_fetch("mike@osada.macgirvin.com")
|
||||
|
||||
text = "@mike@osada.macgirvin.com test"
|
||||
|
||||
mentions = Formatter.parse_mentions(text)
|
||||
|
||||
{subs, text} = Formatter.add_user_links({[], text}, mentions)
|
||||
|
||||
assert length(subs) == 1
|
||||
Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end)
|
||||
|
||||
expected_text =
|
||||
"<span><a class='mention' href='#{mike.ap_id}'>@<span>mike</span></a></span> test"
|
||||
|
||||
assert expected_text == Formatter.finalize({subs, text})
|
||||
end
|
||||
|
||||
test "gives a replacement for single-character local nicknames" do
|
||||
text = "@o hi"
|
||||
o = insert(:user, %{nickname: "o"})
|
||||
|
|
|
@ -3,6 +3,27 @@ defmodule HTTPoisonMock do
|
|||
|
||||
def get(url, body \\ [], headers \\ [])
|
||||
|
||||
def get("https://osada.macgirvin.com/channel/mike", _, _) do
|
||||
{:ok,
|
||||
%Response{
|
||||
status_code: 200,
|
||||
body:
|
||||
File.read!("test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
|
||||
_,
|
||||
_
|
||||
) do
|
||||
{:ok,
|
||||
%Response{
|
||||
status_code: 200,
|
||||
body: File.read!("test/fixtures/httpoison_mock/mike@osada.macgirvin.com.json")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://info.pleroma.site/activity.json", _, _) do
|
||||
{:ok,
|
||||
%Response{
|
||||
|
|
Loading…
Reference in a new issue