[doc] update show
but not use :(
This commit is contained in:
parent
33f9218a8d
commit
ccaa753f79
1 changed files with 63 additions and 18 deletions
|
@ -4,7 +4,7 @@
|
|||
*** Nodeinfo
|
||||
#+begin_src python
|
||||
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.route("/.well-known/nodeinfo")
|
||||
|
@ -44,10 +44,49 @@ def nodeinfo() -> Response:
|
|||
GET http://coscup.localhost/.well-known/nodeinfo
|
||||
#+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
|
||||
GET http://coscup.localhost/nodeinfo/2.0
|
||||
#+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
|
||||
#+begin_src python
|
||||
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
|
||||
#USERNAME = "show"
|
||||
#DOMAIN = "coscup.localhost"
|
||||
#ID = f"http://{DOMAIN}/meow/{USERNAME}"
|
||||
#ID = f"http://{DOMAIN}/user/{USERNAME}"
|
||||
|
||||
@app.route("/.well-known/webfinger")
|
||||
def wellknown_webfinger() -> Response:
|
||||
|
@ -385,7 +424,7 @@ async def _send_accept(...) -> None :
|
|||
|
||||
#+begin_src python
|
||||
def _send_create(...):
|
||||
object_id = BASE_URL + str(uuid.uuid4())
|
||||
object_id =
|
||||
to = []
|
||||
cc = []
|
||||
if visibility == "public":
|
||||
|
@ -396,29 +435,21 @@ def _send_create(...):
|
|||
|
||||
ap_object = {
|
||||
"type": "Note",
|
||||
"id": object_id,
|
||||
"id": BASE_URL + str(uuid.uuid4()),
|
||||
"attributedTo": ID,
|
||||
"content": content,
|
||||
"to": to,
|
||||
"cc": cc,
|
||||
"published": published,
|
||||
"url": object_id,
|
||||
"tag": [],
|
||||
"content": content, # <p>Hello World!<p>
|
||||
"summary": summary,
|
||||
"inReplyTo": reply_id,
|
||||
"sensitive": sensitive,
|
||||
"attachment": [],
|
||||
}
|
||||
|
||||
recipients = set()
|
||||
for actor in get_followers():
|
||||
recipients.add(actor.sharedInbox or actor.inbox_url)
|
||||
ap_object = creat_note(actor, content)
|
||||
|
||||
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:
|
||||
post(inbox_url, ap_object,)
|
||||
for inbox_url in inboxes:
|
||||
client.post(inbox_url, ap_object)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -435,3 +466,17 @@ def wrap_ap_object(...):
|
|||
"type": "Create",
|
||||
}
|
||||
#+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
|
||||
|
|
Loading…
Reference in a new issue