comparison sat/plugins/plugin_comp_ap_gateway/constants.py @ 3745:a8c7e5cef0cb

comp AP gateway: signature checking, caching and threads management: - HTTP signature is checked for incoming messages - AP actor can now be followed using pubsub subscription. When following is accepted, the node is cached - replies to posts are put in cached pubsub comment nodes, with a `comments_max_depth` option to limit the number of comment nodes for a root message (documentation will come to explain this). ticket 364
author Goffi <goffi@goffi.org>
date Tue, 22 Mar 2022 17:00:42 +0100
parents 86eea17cafa7
children 125c7043b277
comparison
equal deleted inserted replaced
3744:658ddbabaf36 3745:a8c7e5cef0cb
20 IMPORT_NAME = "ap-gateway" 20 IMPORT_NAME = "ap-gateway"
21 CONF_SECTION = f"component {IMPORT_NAME}" 21 CONF_SECTION = f"component {IMPORT_NAME}"
22 CONTENT_TYPE_AP = "application/activity+json; charset=utf-8" 22 CONTENT_TYPE_AP = "application/activity+json; charset=utf-8"
23 TYPE_ACTOR = "actor" 23 TYPE_ACTOR = "actor"
24 TYPE_INBOX = "inbox" 24 TYPE_INBOX = "inbox"
25 TYPE_SHARED_INBOX = "shared_inbox"
25 TYPE_OUTBOX = "outbox" 26 TYPE_OUTBOX = "outbox"
26 TYPE_ITEM = "item" 27 TYPE_ITEM = "item"
27 MEDIA_TYPE_AP = "application/activity+json" 28 MEDIA_TYPE_AP = "application/activity+json"
28 # mapping from AP metadata to microblog data 29 # mapping from AP metadata to microblog data
29 AP_MB_MAP = { 30 AP_MB_MAP = {
30 "content": "content_xhtml", 31 "content": "content_xhtml",
31 32
32 } 33 }
33 AP_REQUEST_TYPES = {"actor", "outbox"} 34 AP_REQUEST_TYPES = {
35 "GET": {"actor", "outbox"},
36 "POST": {"inbox"},
37 }
38 # headers to check for signature
39 SIGN_HEADERS = {
40 # headers needed for all HTTP methods
41 None: [
42 # tuples are equivalent headers/pseudo headers, one of them must be present
43 ("date", "(created)"),
44 ("digest", "(request-target)"),
45 ],
46 b"GET": ["host"],
47 b"POST": ["digest"]
48 }
34 PAGE_SIZE = 10 49 PAGE_SIZE = 10
50 HS2019 = "hs2019"
51 # delay after which a signed request is not accepted anymore
52 SIGN_EXP = 12*60*60 # 12 hours (same value as for Mastodon)
35 53
36 LRU_MAX_SIZE = 200 54 LRU_MAX_SIZE = 200
55 ACTIVITY_TYPES = (
56 "Accept", "Add", "Announce", "Arrive", "Block", "Create", "Delete", "Dislike", "Flag",
57 "Follow", "Ignore", "Invite", "Join", "Leave", "Like", "Listen", "Move", "Offer",
58 "Question", "Reject", "Read", "Remove", "TentativeReject", "TentativeAccept",
59 "Travel", "Undo", "Update", "View"
60 )
61 ACTIVITY_TYPES_LOWER = [a.lower() for a in ACTIVITY_TYPES]
62 ACTIVITY_OBJECT_MANDATORY = (
63 "Create", "Update", "Delete", "Follow", "Add", "Remove", "Like", "Block", "Undo"
64 )
65 ACTIVITY_TARGET_MANDATORY = ("Add", "Remove")
66 # activities which can be used with Shared Inbox (i.e. with not account specified)
67 ACTIVIY_NO_ACCOUNT_ALLOWED = ("create",)
68 # maximum number of parents to retrieve when comments_max_depth option is set
69 COMMENTS_MAX_PARENTS = 100