mirror of https://gitlab.com/bashrc2/epicyon
flake8 format
parent
840e726753
commit
295814cd9b
58
metadata.py
58
metadata.py
|
@ -1,24 +1,24 @@
|
||||||
__filename__="metadata.py"
|
__filename__ = "metadata.py"
|
||||||
__author__="Bob Mottram"
|
__author__ = "Bob Mottram"
|
||||||
__license__="AGPL3+"
|
__license__ = "AGPL3+"
|
||||||
__version__="1.1.0"
|
__version__ = "1.1.0"
|
||||||
__maintainer__="Bob Mottram"
|
__maintainer__ = "Bob Mottram"
|
||||||
__email__="bob@freedombone.net"
|
__email__ = "bob@freedombone.net"
|
||||||
__status__="Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import noOfAccounts
|
from utils import noOfAccounts
|
||||||
from utils import noOfActiveAccountsMonthly
|
from utils import noOfActiveAccountsMonthly
|
||||||
|
|
||||||
def metaDataNodeInfo(baseDir: str,registration: bool,version: str) -> {}:
|
|
||||||
|
def metaDataNodeInfo(baseDir: str, registration: bool, version: str) -> {}:
|
||||||
""" /nodeinfo/2.0 endpoint
|
""" /nodeinfo/2.0 endpoint
|
||||||
"""
|
"""
|
||||||
activeAccounts=noOfAccounts(baseDir)
|
activeAccounts = noOfAccounts(baseDir)
|
||||||
activeAccountsMonthly=noOfActiveAccountsMonthly(baseDir,1)
|
activeAccountsMonthly = noOfActiveAccountsMonthly(baseDir, 1)
|
||||||
activeAccountsHalfYear=noOfActiveAccountsMonthly(baseDir,6)
|
activeAccountsHalfYear = noOfActiveAccountsMonthly(baseDir, 6)
|
||||||
nodeinfo={
|
nodeinfo = {
|
||||||
'openRegistrations': registration,
|
'openRegistrations': registration,
|
||||||
'protocols': ['activitypub'],
|
'protocols': ['activitypub'],
|
||||||
'software': {
|
'software': {
|
||||||
|
@ -37,29 +37,35 @@ def metaDataNodeInfo(baseDir: str,registration: bool,version: str) -> {}:
|
||||||
}
|
}
|
||||||
return nodeinfo
|
return nodeinfo
|
||||||
|
|
||||||
def metaDataInstance(instanceTitle: str, \
|
|
||||||
instanceDescriptionShort: str, \
|
def metaDataInstance(instanceTitle: str,
|
||||||
instanceDescription: str, \
|
instanceDescriptionShort: str,
|
||||||
httpPrefix: str,baseDir: str, \
|
instanceDescription: str,
|
||||||
adminNickname: str,domain: str,domainFull: str, \
|
httpPrefix: str, baseDir: str,
|
||||||
registration: bool,systemLanguage: str, \
|
adminNickname: str, domain: str, domainFull: str,
|
||||||
|
registration: bool, systemLanguage: str,
|
||||||
version: str) -> {}:
|
version: str) -> {}:
|
||||||
""" /api/v1/instance endpoint
|
""" /api/v1/instance endpoint
|
||||||
"""
|
"""
|
||||||
adminActorFilename=baseDir+'/accounts/'+adminNickname+'@'+domain+'.json'
|
adminActorFilename = \
|
||||||
|
baseDir + '/accounts/' + adminNickname + '@' + domain + '.json'
|
||||||
if not os.path.isfile(adminActorFilename):
|
if not os.path.isfile(adminActorFilename):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
adminActor=loadJson(adminActorFilename,0)
|
adminActor = loadJson(adminActorFilename, 0)
|
||||||
if not adminActor:
|
if not adminActor:
|
||||||
print('WARN: json load exception metaDataInstance')
|
print('WARN: json load exception metaDataInstance')
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
isBot=False
|
isBot = False
|
||||||
if adminActor['type']!='Person':
|
if adminActor['type'] != 'Person':
|
||||||
isBot=True
|
isBot = True
|
||||||
|
|
||||||
instance={
|
url = \
|
||||||
|
httpPrefix + '://' + domainFull + '/@' + \
|
||||||
|
adminActor['preferredUsername']
|
||||||
|
|
||||||
|
instance = {
|
||||||
'approval_required': False,
|
'approval_required': False,
|
||||||
'contact_account': {
|
'contact_account': {
|
||||||
'acct': adminActor['preferredUsername'],
|
'acct': adminActor['preferredUsername'],
|
||||||
|
@ -79,7 +85,7 @@ def metaDataInstance(instanceTitle: str, \
|
||||||
'locked': adminActor['manuallyApprovesFollowers'],
|
'locked': adminActor['manuallyApprovesFollowers'],
|
||||||
'note': '<p>Admin of '+domain+'</p>',
|
'note': '<p>Admin of '+domain+'</p>',
|
||||||
'statuses_count': 1,
|
'statuses_count': 1,
|
||||||
'url': httpPrefix+'://'+domainFull+'/@'+adminActor['preferredUsername'],
|
'url': url,
|
||||||
'username': adminActor['preferredUsername']
|
'username': adminActor['preferredUsername']
|
||||||
},
|
},
|
||||||
'description': instanceDescription,
|
'description': instanceDescription,
|
||||||
|
|
Loading…
Reference in New Issue