Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_comp_ap_gateway/constants.py @ 4071:4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 11:49:51 +0200 |
parents | sat/plugins/plugin_comp_ap_gateway/constants.py@d538b07cddf3 |
children | ec9bed9df74f |
comparison
equal
deleted
inserted
replaced
4070:d10748475025 | 4071:4b842c1fb686 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 # Libervia ActivityPub Gateway | |
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 | |
20 IMPORT_NAME = "ap-gateway" | |
21 CONF_SECTION = f"component {IMPORT_NAME}" | |
22 CONTENT_TYPE_AP = "application/activity+json; charset=utf-8" | |
23 TYPE_ACTOR = "actor" | |
24 TYPE_INBOX = "inbox" | |
25 TYPE_SHARED_INBOX = "shared_inbox" | |
26 TYPE_OUTBOX = "outbox" | |
27 TYPE_FOLLOWERS = "followers" | |
28 TYPE_FOLLOWING = "following" | |
29 TYPE_ITEM = "item" | |
30 TYPE_TOMBSTONE = "Tombstone" | |
31 TYPE_MENTION = "Mention" | |
32 TYPE_LIKE = "Like" | |
33 TYPE_REACTION = "EmojiReact" | |
34 TYPE_EVENT = "Event" | |
35 TYPE_JOIN = "Join" | |
36 TYPE_LEAVE = "Leave" | |
37 MEDIA_TYPE_AP = "application/activity+json" | |
38 NS_AP = "https://www.w3.org/ns/activitystreams" | |
39 NS_AP_PUBLIC = f"{NS_AP}#Public" | |
40 # 3 values can be used, see https://www.w3.org/TR/activitypub/#public-addressing | |
41 PUBLIC_TUPLE = (NS_AP_PUBLIC, "as:Public", "Public") | |
42 AP_REQUEST_TYPES = { | |
43 "GET": {TYPE_ACTOR, TYPE_OUTBOX, TYPE_FOLLOWERS, TYPE_FOLLOWING}, | |
44 "POST": {"inbox"}, | |
45 } | |
46 AP_REQUEST_TYPES["HEAD"] = AP_REQUEST_TYPES["GET"] | |
47 # headers to check for signature | |
48 SIGN_HEADERS = { | |
49 # headers needed for all HTTP methods | |
50 None: [ | |
51 # tuples are equivalent headers/pseudo headers, one of them must be present | |
52 ("date", "(created)"), | |
53 ("digest", "(request-target)"), | |
54 ], | |
55 b"GET": ["host"], | |
56 b"POST": ["digest"] | |
57 } | |
58 PAGE_SIZE = 10 | |
59 HS2019 = "hs2019" | |
60 # delay after which a signed request is not accepted anymore | |
61 SIGN_EXP = 12*60*60 # 12 hours (same value as for Mastodon) | |
62 | |
63 LRU_MAX_SIZE = 200 | |
64 ACTIVITY_TYPES = ( | |
65 "Accept", "Add", "Announce", "Arrive", "Block", "Create", "Delete", "Dislike", "Flag", | |
66 "Follow", "Ignore", "Invite", "Join", "Leave", "Like", "Listen", "Move", "Offer", | |
67 "Question", "Reject", "Read", "Remove", "TentativeReject", "TentativeAccept", | |
68 "Travel", "Undo", "Update", "View", | |
69 # non-standard activities | |
70 "EmojiReact" | |
71 ) | |
72 ACTIVITY_TYPES_LOWER = [a.lower() for a in ACTIVITY_TYPES] | |
73 ACTIVITY_OBJECT_MANDATORY = ( | |
74 "Create", "Update", "Delete", "Follow", "Add", "Remove", "Like", "Block", "Undo" | |
75 ) | |
76 ACTIVITY_TARGET_MANDATORY = ("Add", "Remove") | |
77 # activities which can be used with Shared Inbox (i.e. with no account specified) | |
78 # must be lowercase | |
79 ACTIVIY_NO_ACCOUNT_ALLOWED = ( | |
80 "create", "update", "delete", "announce", "undo", "like", "emojireact", "join", | |
81 "leave" | |
82 ) | |
83 # maximum number of parents to retrieve when comments_max_depth option is set | |
84 COMMENTS_MAX_PARENTS = 100 | |
85 # maximum size of avatar, in bytes | |
86 MAX_AVATAR_SIZE = 1024 * 1024 * 5 | |
87 | |
88 # storage prefixes | |
89 ST_AVATAR = "[avatar]" | |
90 ST_AP_CACHE = "[AP_item_cache]" |