[doc] update show

but not use :(
This commit is contained in:
SouthFox 2023-07-27 15:15:17 +08:00
parent 33f9218a8d
commit ccaa753f79

View file

@ -4,7 +4,7 @@
*** Nodeinfo *** Nodeinfo
#+begin_src python #+begin_src python
from flask import Flask, Response, jsonify from flask import Flask, Response, jsonify
from config import BASE_URL #http://coscup.localhost from config import BASE_URL #https://alice.me
app = Flask(__name__) app = Flask(__name__)
@app.route("/.well-known/nodeinfo") @app.route("/.well-known/nodeinfo")
@ -44,10 +44,49 @@ def nodeinfo() -> Response:
GET http://coscup.localhost/.well-known/nodeinfo GET http://coscup.localhost/.well-known/nodeinfo
#+end_src #+end_src
#+RESULTS:
#+BEGIN_SRC js
// GET http://coscup.localhost/.well-known/nodeinfo
// HTTP/1.1 503 Service Unavailable
// Connection: close
// Proxy-Connection: close
// Content-Length: 0
// Request duration: 2.318918s
#+END_SRC
#+RESULTS:
#+begin_src restclient #+begin_src restclient
GET http://coscup.localhost/nodeinfo/2.0 GET http://coscup.localhost/nodeinfo/2.0
#+end_src #+end_src
#+RESULTS:
#+BEGIN_SRC js
// GET https://alice.me/nodeinfo/2.0
{
"version": "2.0"
"openRegistrations": false,
"protocols": ["activitypub"],
"software": {
"name": "COSCUP-demo",
"version": "0.0.1"
},
"usage": {
"users": {
"total": 1
}
},
}
// HTTP/1.1 200 OK
// Server: nginx/1.24.0
// Date: Fri, 14 Jul 2023 07:35:20 GMT
// Content-Type: application/json
// Content-Length: 297
// Connection: keep-alive
// Request duration: 0.002971s
#+END_SRC
*** Actor *** Actor
#+begin_src python #+begin_src python
AS_CTX = "https://www.w3.org/ns/activitystreams" AS_CTX = "https://www.w3.org/ns/activitystreams"
@ -124,7 +163,7 @@ from flask import Flask, abort, request, Response, jsonify
from config import USERNAME, DOMAIN, ID from config import USERNAME, DOMAIN, ID
#USERNAME = "show" #USERNAME = "show"
#DOMAIN = "coscup.localhost" #DOMAIN = "coscup.localhost"
#ID = f"http://{DOMAIN}/meow/{USERNAME}" #ID = f"http://{DOMAIN}/user/{USERNAME}"
@app.route("/.well-known/webfinger") @app.route("/.well-known/webfinger")
def wellknown_webfinger() -> Response: def wellknown_webfinger() -> Response:
@ -385,7 +424,7 @@ async def _send_accept(...) -> None :
#+begin_src python #+begin_src python
def _send_create(...): def _send_create(...):
object_id = BASE_URL + str(uuid.uuid4()) object_id =
to = [] to = []
cc = [] cc = []
if visibility == "public": if visibility == "public":
@ -396,29 +435,21 @@ def _send_create(...):
ap_object = { ap_object = {
"type": "Note", "type": "Note",
"id": object_id, "id": BASE_URL + str(uuid.uuid4()),
"attributedTo": ID, "attributedTo": ID,
"content": content, "content": content,
"to": to, "to": to,
"cc": cc,
"published": published,
"url": object_id,
"tag": [],
"content": content, # <p>Hello World!<p> "content": content, # <p>Hello World!<p>
"summary": summary,
"inReplyTo": reply_id,
"sensitive": sensitive,
"attachment": [],
} }
recipients = set() ap_object = creat_note(actor, content)
for actor in get_followers():
recipients.add(actor.sharedInbox or actor.inbox_url)
ap_object = wrap_ap_object(ap_object) inboxes = set()
for follower in get_followers():
inboxes.add(follower.sharedInbox or follower.inbox_url)
for inbox_url in recipients: for inbox_url in inboxes:
post(inbox_url, ap_object,) client.post(inbox_url, ap_object)
return True return True
@ -435,3 +466,17 @@ def wrap_ap_object(...):
"type": "Create", "type": "Create",
} }
#+end_src #+end_src
#+begin_src json
{"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"id": "https://alice.me/a29a6843-9feb-4c74-a7f7-081b9c9201d3",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"actor": "https://alice.me/meow/alice",
"object": {"type": "Note",
"id": "https://alice.me/49e2d03d-b53a-4c4c-a95c-94a6abf45a19",
"attributedTo": "https://alice.me/meow/alice",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"content": "Hello world!"}}
#+end_src