mirror of https://gitlab.com/bashrc2/epicyon
Move function
parent
c4d4dc5d63
commit
de94fdc1f1
|
@ -15,6 +15,7 @@ from person import deactivateAccount
|
|||
from skills import setSkillLevel
|
||||
from roles import setRole
|
||||
from webfinger import webfingerHandle
|
||||
from posts import downloadFollowersCollection
|
||||
from posts import getPublicPostDomains
|
||||
from posts import getPublicPostDomainsBlocked
|
||||
from posts import sendBlockViaServer
|
||||
|
@ -75,7 +76,6 @@ from announce import sendAnnounceViaServer
|
|||
from socnet import instancesGraph
|
||||
from migrate import migrateAccounts
|
||||
import argparse
|
||||
from webapp_utils import downloadFollowersCollection
|
||||
|
||||
|
||||
def str2bool(v) -> bool:
|
||||
|
|
31
posts.py
31
posts.py
|
@ -3376,6 +3376,37 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
|
|||
return postDomains
|
||||
|
||||
|
||||
def downloadFollowersCollection(session, httpPrefix,
|
||||
actor: str, pageNumber=1,
|
||||
noOfPages=1) -> []:
|
||||
"""Returns a list of followers for the given actor
|
||||
by downloading the json for their followers collection
|
||||
"""
|
||||
prof = 'https://www.w3.org/ns/activitystreams'
|
||||
if '/channel/' not in actor or '/accounts/' not in actor:
|
||||
sessionHeaders = {
|
||||
'Accept': 'application/activity+json; profile="' + prof + '"'
|
||||
}
|
||||
else:
|
||||
sessionHeaders = {
|
||||
'Accept': 'application/ld+json; profile="' + prof + '"'
|
||||
}
|
||||
result = []
|
||||
for pageCtr in range(noOfPages):
|
||||
followersJson = \
|
||||
getJson(session, actor + '/followers?page=' +
|
||||
str(pageNumber + pageCtr),
|
||||
sessionHeaders, None, __version__, httpPrefix, None)
|
||||
if followersJson:
|
||||
if followersJson.get('orderedItems'):
|
||||
result += followersJson['orderedItems']
|
||||
else:
|
||||
break
|
||||
else:
|
||||
break
|
||||
return result
|
||||
|
||||
|
||||
def getPublicPostInfo(session, baseDir: str, nickname: str, domain: str,
|
||||
proxyType: str, port: int, httpPrefix: str,
|
||||
debug: bool, projectVersion: str) -> []:
|
||||
|
|
|
@ -868,34 +868,3 @@ def getAvatarImageUrl(session,
|
|||
avatarUrl = postActor + '/avatar.png'
|
||||
|
||||
return avatarUrl
|
||||
|
||||
|
||||
def downloadFollowersCollection(session, httpPrefix,
|
||||
actor: str, pageNumber=1,
|
||||
noOfPages=1) -> []:
|
||||
"""Returns a list of followers for the given actor
|
||||
by downloading the json for their followers collection
|
||||
"""
|
||||
prof = 'https://www.w3.org/ns/activitystreams'
|
||||
if '/channel/' not in actor or '/accounts/' not in actor:
|
||||
sessionHeaders = {
|
||||
'Accept': 'application/activity+json; profile="' + prof + '"'
|
||||
}
|
||||
else:
|
||||
sessionHeaders = {
|
||||
'Accept': 'application/ld+json; profile="' + prof + '"'
|
||||
}
|
||||
result = []
|
||||
for pageCtr in range(noOfPages):
|
||||
followersJson = \
|
||||
getJson(session, actor + '/followers?page=' +
|
||||
str(pageNumber + pageCtr),
|
||||
sessionHeaders, None, __version__, httpPrefix, None)
|
||||
if followersJson:
|
||||
if followersJson.get('orderedItems'):
|
||||
result += followersJson['orderedItems']
|
||||
else:
|
||||
break
|
||||
else:
|
||||
break
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue