mirror of https://gitlab.com/bashrc2/epicyon
Unify permission to publish metadata
parent
66e9128361
commit
74f2103cc7
18
daemon.py
18
daemon.py
|
@ -877,7 +877,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
registration: bool,
|
registration: bool,
|
||||||
systemLanguage: str,
|
systemLanguage: str,
|
||||||
projectVersion: str,
|
projectVersion: str,
|
||||||
customEmoji: []) -> bool:
|
customEmoji: [],
|
||||||
|
showNodeInfoAccounts: bool) -> bool:
|
||||||
"""This is a vestigil mastodon API for the purpose
|
"""This is a vestigil mastodon API for the purpose
|
||||||
of returning an empty result to sites like
|
of returning an empty result to sites like
|
||||||
https://mastopeek.app-dist.eu
|
https://mastopeek.app-dist.eu
|
||||||
|
@ -977,8 +978,12 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
domainFull = i2pDomain
|
domainFull = i2pDomain
|
||||||
httpPrefix = 'http'
|
httpPrefix = 'http'
|
||||||
|
|
||||||
|
if brochModeIsActive(baseDir):
|
||||||
|
showNodeInfoAccounts = False
|
||||||
|
|
||||||
sendJson = \
|
sendJson = \
|
||||||
metaDataInstance(instanceTitle,
|
metaDataInstance(showNodeInfoAccounts,
|
||||||
|
instanceTitle,
|
||||||
instanceDescriptionShort,
|
instanceDescriptionShort,
|
||||||
instanceDescription,
|
instanceDescription,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
|
@ -1033,12 +1038,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
registration: bool,
|
registration: bool,
|
||||||
systemLanguage: str,
|
systemLanguage: str,
|
||||||
projectVersion: str,
|
projectVersion: str,
|
||||||
customEmoji: []) -> bool:
|
customEmoji: [],
|
||||||
|
showNodeInfoAccounts: bool) -> bool:
|
||||||
return self._mastoApiV1(path, callingDomain, authorized,
|
return self._mastoApiV1(path, callingDomain, authorized,
|
||||||
httpPrefix, baseDir, nickname, domain,
|
httpPrefix, baseDir, nickname, domain,
|
||||||
domainFull, onionDomain, i2pDomain,
|
domainFull, onionDomain, i2pDomain,
|
||||||
translate, registration, systemLanguage,
|
translate, registration, systemLanguage,
|
||||||
projectVersion, customEmoji)
|
projectVersion, customEmoji,
|
||||||
|
showNodeInfoAccounts)
|
||||||
|
|
||||||
def _nodeinfo(self, callingDomain: str) -> bool:
|
def _nodeinfo(self, callingDomain: str) -> bool:
|
||||||
if not self.path.startswith('/nodeinfo/2.0'):
|
if not self.path.startswith('/nodeinfo/2.0'):
|
||||||
|
@ -10849,7 +10856,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.registration,
|
self.server.registration,
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
self.server.projectVersion,
|
self.server.projectVersion,
|
||||||
self.server.customEmoji):
|
self.server.customEmoji,
|
||||||
|
self.server.showNodeInfoAccounts):
|
||||||
return
|
return
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
|
|
114
metadata.py
114
metadata.py
|
@ -12,54 +12,6 @@ from utils import noOfAccounts
|
||||||
from utils import noOfActiveAccountsMonthly
|
from utils import noOfActiveAccountsMonthly
|
||||||
|
|
||||||
|
|
||||||
def metaDataNodeInfo(baseDir: str,
|
|
||||||
aboutUrl: str,
|
|
||||||
termsOfServiceUrl: str,
|
|
||||||
registration: bool, version: str,
|
|
||||||
showAccounts: bool) -> {}:
|
|
||||||
""" /nodeinfo/2.0 endpoint
|
|
||||||
Also see https://socialhub.activitypub.rocks/t/
|
|
||||||
fep-f1d5-nodeinfo-in-fediverse-software/1190/4
|
|
||||||
|
|
||||||
Note that there are security considerations with this. If an adversary
|
|
||||||
sees a lot of accounts and "local" posts then the instance may be
|
|
||||||
considered a higher priority target.
|
|
||||||
Also exposure of the version number and number of accounts could be
|
|
||||||
sensitive
|
|
||||||
"""
|
|
||||||
if showAccounts:
|
|
||||||
activeAccounts = noOfAccounts(baseDir)
|
|
||||||
activeAccountsMonthly = noOfActiveAccountsMonthly(baseDir, 1)
|
|
||||||
activeAccountsHalfYear = noOfActiveAccountsMonthly(baseDir, 6)
|
|
||||||
else:
|
|
||||||
activeAccounts = 1
|
|
||||||
activeAccountsMonthly = 1
|
|
||||||
activeAccountsHalfYear = 1
|
|
||||||
|
|
||||||
nodeinfo = {
|
|
||||||
'openRegistrations': registration,
|
|
||||||
'protocols': ['activitypub'],
|
|
||||||
'software': {
|
|
||||||
'name': 'epicyon',
|
|
||||||
'version': version
|
|
||||||
},
|
|
||||||
'documents': {
|
|
||||||
'about': aboutUrl,
|
|
||||||
'terms': termsOfServiceUrl
|
|
||||||
},
|
|
||||||
'usage': {
|
|
||||||
'localPosts': 1,
|
|
||||||
'users': {
|
|
||||||
'activeHalfyear': activeAccountsHalfYear,
|
|
||||||
'activeMonth': activeAccountsMonthly,
|
|
||||||
'total': activeAccounts
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'version': '2.0'
|
|
||||||
}
|
|
||||||
return nodeinfo
|
|
||||||
|
|
||||||
|
|
||||||
def _getStatusCount(baseDir: str) -> int:
|
def _getStatusCount(baseDir: str) -> int:
|
||||||
"""Get the total number of posts
|
"""Get the total number of posts
|
||||||
"""
|
"""
|
||||||
|
@ -79,7 +31,58 @@ def _getStatusCount(baseDir: str) -> int:
|
||||||
return statusCtr
|
return statusCtr
|
||||||
|
|
||||||
|
|
||||||
def metaDataInstance(instanceTitle: str,
|
def metaDataNodeInfo(baseDir: str,
|
||||||
|
aboutUrl: str,
|
||||||
|
termsOfServiceUrl: str,
|
||||||
|
registration: bool, version: str,
|
||||||
|
showAccounts: bool) -> {}:
|
||||||
|
""" /nodeinfo/2.0 endpoint
|
||||||
|
Also see https://socialhub.activitypub.rocks/t/
|
||||||
|
fep-f1d5-nodeinfo-in-fediverse-software/1190/4
|
||||||
|
|
||||||
|
Note that there are security considerations with this. If an adversary
|
||||||
|
sees a lot of accounts and "local" posts then the instance may be
|
||||||
|
considered a higher priority target.
|
||||||
|
Also exposure of the version number and number of accounts could be
|
||||||
|
sensitive
|
||||||
|
"""
|
||||||
|
if showAccounts:
|
||||||
|
activeAccounts = noOfAccounts(baseDir)
|
||||||
|
activeAccountsMonthly = noOfActiveAccountsMonthly(baseDir, 1)
|
||||||
|
activeAccountsHalfYear = noOfActiveAccountsMonthly(baseDir, 6)
|
||||||
|
localPosts = _getStatusCount(baseDir)
|
||||||
|
else:
|
||||||
|
activeAccounts = 1
|
||||||
|
activeAccountsMonthly = 1
|
||||||
|
activeAccountsHalfYear = 1
|
||||||
|
localPosts = 1
|
||||||
|
|
||||||
|
nodeinfo = {
|
||||||
|
'openRegistrations': registration,
|
||||||
|
'protocols': ['activitypub'],
|
||||||
|
'software': {
|
||||||
|
'name': 'epicyon',
|
||||||
|
'version': version
|
||||||
|
},
|
||||||
|
'documents': {
|
||||||
|
'about': aboutUrl,
|
||||||
|
'terms': termsOfServiceUrl
|
||||||
|
},
|
||||||
|
'usage': {
|
||||||
|
'localPosts': localPosts,
|
||||||
|
'users': {
|
||||||
|
'activeHalfyear': activeAccountsHalfYear,
|
||||||
|
'activeMonth': activeAccountsMonthly,
|
||||||
|
'total': activeAccounts
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'version': '2.0'
|
||||||
|
}
|
||||||
|
return nodeinfo
|
||||||
|
|
||||||
|
|
||||||
|
def metaDataInstance(showAccounts: bool,
|
||||||
|
instanceTitle: str,
|
||||||
instanceDescriptionShort: str,
|
instanceDescriptionShort: str,
|
||||||
instanceDescription: str,
|
instanceDescription: str,
|
||||||
httpPrefix: str, baseDir: str,
|
httpPrefix: str, baseDir: str,
|
||||||
|
@ -106,6 +109,13 @@ def metaDataInstance(instanceTitle: str,
|
||||||
httpPrefix + '://' + domainFull + '/@' + \
|
httpPrefix + '://' + domainFull + '/@' + \
|
||||||
adminActor['preferredUsername']
|
adminActor['preferredUsername']
|
||||||
|
|
||||||
|
if showAccounts:
|
||||||
|
activeAccounts = noOfAccounts(baseDir)
|
||||||
|
localPosts = _getStatusCount(baseDir)
|
||||||
|
else:
|
||||||
|
activeAccounts = 1
|
||||||
|
localPosts = 1
|
||||||
|
|
||||||
instance = {
|
instance = {
|
||||||
'approval_required': False,
|
'approval_required': False,
|
||||||
'contact_account': {
|
'contact_account': {
|
||||||
|
@ -126,9 +136,9 @@ def metaDataInstance(instanceTitle: str,
|
||||||
'registrations': registration,
|
'registrations': registration,
|
||||||
'short_description': instanceDescriptionShort,
|
'short_description': instanceDescriptionShort,
|
||||||
'stats': {
|
'stats': {
|
||||||
'domain_count': 2,
|
'domain_count': 1,
|
||||||
'status_count': _getStatusCount(baseDir),
|
'status_count': localPosts,
|
||||||
'user_count': noOfAccounts(baseDir)
|
'user_count': activeAccounts
|
||||||
},
|
},
|
||||||
'thumbnail': httpPrefix + '://' + domainFull + '/login.png',
|
'thumbnail': httpPrefix + '://' + domainFull + '/login.png',
|
||||||
'title': instanceTitle,
|
'title': instanceTitle,
|
||||||
|
|
Loading…
Reference in New Issue