Skip to content
Snippets Groups Projects
Commit 6386c1c9 authored by Sachin Joshi's avatar Sachin Joshi
Browse files

fetch url for OStatus to know if it is a/c or status

parent 1d01e8e6
Branches
No related tags found
No related merge requests found
......@@ -103,8 +103,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
defp is_status?(acct) do
%URI{path: path} = URI.parse(acct)
Regex.match?(~r/\/users\/[^\/]+\/statuses\/([0-9]+)$/, path)
case ActivityPub.fetch_and_contain_remote_object_from_id(acct) do
{:ok, %{"type" => "Note"}} -> true
_ -> false
end
end
def do_remote_follow(conn, %{
......
This diff is collapsed.
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"toot": "http://joinmastodon.org/ns#",
"featured": {
"@id": "toot:featured",
"@type": "@id"
},
"alsoKnownAs": {
"@id": "as:alsoKnownAs",
"@type": "@id"
},
"movedTo": {
"@id": "as:movedTo",
"@type": "@id"
},
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"Hashtag": "as:Hashtag",
"Emoji": "toot:Emoji",
"IdentityProof": "toot:IdentityProof",
"focalPoint": {
"@container": "@list",
"@id": "toot:focalPoint"
}
}
],
"id": "https://mastodon.social/users/emelie",
"type": "Person",
"following": "https://mastodon.social/users/emelie/following",
"followers": "https://mastodon.social/users/emelie/followers",
"inbox": "https://mastodon.social/users/emelie/inbox",
"outbox": "https://mastodon.social/users/emelie/outbox",
"featured": "https://mastodon.social/users/emelie/collections/featured",
"preferredUsername": "emelie",
"name": "emelie 🎨",
"summary": "<p>23 / <a href=\"https://mastodon.social/tags/sweden\" class=\"mention hashtag\" rel=\"tag\">#<span>Sweden</span></a> / <a href=\"https://mastodon.social/tags/artist\" class=\"mention hashtag\" rel=\"tag\">#<span>Artist</span></a> / <a href=\"https://mastodon.social/tags/equestrian\" class=\"mention hashtag\" rel=\"tag\">#<span>Equestrian</span></a> / <a href=\"https://mastodon.social/tags/gamedev\" class=\"mention hashtag\" rel=\"tag\">#<span>GameDev</span></a></p><p>If I ain&apos;t spending time with my pets, I&apos;m probably drawing. 🐴 🐱 🐰</p>",
"url": "https://mastodon.social/@emelie",
"manuallyApprovesFollowers": false,
"publicKey": {
"id": "https://mastodon.social/users/emelie#main-key",
"owner": "https://mastodon.social/users/emelie",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu3CWs1oAJPE3ZJ9sj6Ut\n/Mu+mTE7MOijsQc8/6c73XVVuhIEomiozJIH7l8a7S1n5SYL4UuiwcubSOi7u1bb\nGpYnp5TYhN+Cxvq/P80V4/ncNIPSQzS49it7nSLeG5pA21lGPDA44huquES1un6p\n9gSmbTwngVX9oe4MYuUeh0Z7vijjU13Llz1cRq/ZgPQPgfz+2NJf+VeXnvyDZDYx\nZPVBBlrMl3VoGbu0M5L8SjY35559KCZ3woIvqRolcoHXfgvJMdPcJgSZVYxlCw3d\nA95q9jQcn6s87CPSUs7bmYEQCrDVn5m5NER5TzwBmP4cgJl9AaDVWQtRd4jFZNTx\nlQIDAQAB\n-----END PUBLIC KEY-----\n"
},
"tag": [
{
"type": "Hashtag",
"href": "https://mastodon.social/explore/sweden",
"name": "#sweden"
},
{
"type": "Hashtag",
"href": "https://mastodon.social/explore/gamedev",
"name": "#gamedev"
},
{
"type": "Hashtag",
"href": "https://mastodon.social/explore/artist",
"name": "#artist"
},
{
"type": "Hashtag",
"href": "https://mastodon.social/explore/equestrian",
"name": "#equestrian"
}
],
"attachment": [
{
"type": "PropertyValue",
"name": "Ko-fi",
"value": "<a href=\"https://ko-fi.com/emeliepng\" rel=\"me nofollow noopener\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">ko-fi.com/emeliepng</span><span class=\"invisible\"></span></a>"
},
{
"type": "PropertyValue",
"name": "Instagram",
"value": "<a href=\"https://www.instagram.com/emelie_png/\" rel=\"me nofollow noopener\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"\">instagram.com/emelie_png/</span><span class=\"invisible\"></span></a>"
},
{
"type": "PropertyValue",
"name": "Carrd",
"value": "<a href=\"https://emelie.carrd.co/\" rel=\"me nofollow noopener\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">emelie.carrd.co/</span><span class=\"invisible\"></span></a>"
},
{
"type": "PropertyValue",
"name": "Artstation",
"value": "<a href=\"https://emiri.artstation.com\" rel=\"me nofollow noopener\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">emiri.artstation.com</span><span class=\"invisible\"></span></a>"
}
],
"endpoints": {
"sharedInbox": "https://mastodon.social/inbox"
},
"icon": {
"type": "Image",
"mediaType": "image/png",
"url": "https://files.mastodon.social/accounts/avatars/000/015/657/original/e7163f98280da1a4.png"
},
"image": {
"type": "Image",
"mediaType": "image/png",
"url": "https://files.mastodon.social/accounts/headers/000/015/657/original/847f331f3dd9e38b.png"
}
}
{
"aliases": [
"https://mastodon.social/@emelie",
"https://mastodon.social/users/emelie"
],
"links": [
{
"href": "https://mastodon.social/@emelie",
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html"
},
{
"href": "https://mastodon.social/users/emelie.atom",
"rel": "http://schemas.google.com/g/2010#updates-from",
"type": "application/atom+xml"
},
{
"href": "https://mastodon.social/users/emelie",
"rel": "self",
"type": "application/activity+json"
},
{
"href": "https://mastodon.social/api/salmon/15657",
"rel": "salmon"
},
{
"href": "data:application/magic-public-key,RSA.u3CWs1oAJPE3ZJ9sj6Ut_Mu-mTE7MOijsQc8_6c73XVVuhIEomiozJIH7l8a7S1n5SYL4UuiwcubSOi7u1bbGpYnp5TYhN-Cxvq_P80V4_ncNIPSQzS49it7nSLeG5pA21lGPDA44huquES1un6p9gSmbTwngVX9oe4MYuUeh0Z7vijjU13Llz1cRq_ZgPQPgfz-2NJf-VeXnvyDZDYxZPVBBlrMl3VoGbu0M5L8SjY35559KCZ3woIvqRolcoHXfgvJMdPcJgSZVYxlCw3dA95q9jQcn6s87CPSUs7bmYEQCrDVn5m5NER5TzwBmP4cgJl9AaDVWQtRd4jFZNTxlQ==.AQAB",
"rel": "magic-public-key"
},
{
"rel": "http://ostatus.org/schema/1.0/subscribe",
"template": "https://mastodon.social/authorize_interaction?uri={uri}"
}
],
"subject": "acct:emelie@mastodon.social"
}
......@@ -52,6 +52,27 @@ defmodule HttpRequestMock do
}}
end
def get(
"https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/emelie",
_,
_,
_
) do
{:ok,
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/httpoison_mock/webfinger_emelie.json")
}}
end
def get("https://mastodon.social/users/emelie.atom", _, _, _) do
{:ok,
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/httpoison_mock/emelie.atom")
}}
end
def get(
"https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
_,
......
......@@ -180,5 +180,15 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
assert redirected_to(conn) =~ "/notice/"
end
test "show follow account page if the `acct` is a account link", %{conn: conn} do
response =
get(
conn,
"/ostatus_subscribe?acct=https://mastodon.social/users/emelie"
)
assert html_response(response, 200) =~ "Log in to follow"
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment