epicyon.py 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  1. __filename__ = "epicyon.py"
  2. __author__ = "Bob Mottram"
  3. __license__ = "AGPL3+"
  4. __version__ = "0.0.1"
  5. __maintainer__ = "Bob Mottram"
  6. __email__ = "bob@freedombone.net"
  7. __status__ = "Production"
  8. from person import createPerson
  9. from person import createSharedInbox
  10. from person import createCapabilitiesInbox
  11. from person import setPreferredNickname
  12. from person import setBio
  13. from person import setProfileImage
  14. from person import removeAccount
  15. from skills import setSkillLevel
  16. from roles import setRole
  17. from person import setOrganizationScheme
  18. from webfinger import webfingerHandle
  19. from posts import getPosts
  20. from posts import createPublicPost
  21. from posts import deleteAllPosts
  22. from posts import createOutbox
  23. from posts import archivePosts
  24. from posts import sendPostViaServer
  25. from posts import getPublicPostsOfPerson
  26. from posts import getUserUrl
  27. from posts import archivePosts
  28. from session import createSession
  29. from session import getJson
  30. from blocking import addBlock
  31. from blocking import removeBlock
  32. from filters import addFilter
  33. from filters import removeFilter
  34. import json
  35. import os
  36. import shutil
  37. import sys
  38. import requests
  39. import time
  40. from pprint import pprint
  41. from tests import testHttpsig
  42. from daemon import runDaemon
  43. import socket
  44. from follow import clearFollows
  45. from follow import clearFollowers
  46. from follow import followerOfPerson
  47. from follow import unfollowPerson
  48. from follow import unfollowerOfPerson
  49. from follow import getFollowersOfPerson
  50. from tests import testPostMessageBetweenServers
  51. from tests import testFollowBetweenServers
  52. from tests import testClientToServer
  53. from tests import runAllTests
  54. from config import setConfigParam
  55. from config import getConfigParam
  56. from auth import storeBasicCredentials
  57. from auth import removePassword
  58. from auth import createPassword
  59. from utils import getDomainFromActor
  60. from utils import getNicknameFromActor
  61. from utils import followPerson
  62. from utils import validNickname
  63. from media import archiveMedia
  64. from delete import sendDeleteViaServer
  65. from like import sendLikeViaServer
  66. from like import sendUndoLikeViaServer
  67. from blocking import sendBlockViaServer
  68. from blocking import sendUndoBlockViaServer
  69. from roles import sendRoleViaServer
  70. from skills import sendSkillViaServer
  71. from availability import setAvailability
  72. from availability import sendAvailabilityViaServer
  73. from manualapprove import manualDenyFollowRequest
  74. from manualapprove import manualApproveFollowRequest
  75. from shares import sendShareViaServer
  76. from shares import sendUndoShareViaServer
  77. from shares import addShare
  78. import argparse
  79. def str2bool(v):
  80. if isinstance(v, bool):
  81. return v
  82. if v.lower() in ('yes', 'true', 't', 'y', '1'):
  83. return True
  84. elif v.lower() in ('no', 'false', 'f', 'n', '0'):
  85. return False
  86. else:
  87. raise argparse.ArgumentTypeError('Boolean value expected.')
  88. parser = argparse.ArgumentParser(description='ActivityPub Server')
  89. parser.add_argument('-n','--nickname', dest='nickname', type=str,default=None, \
  90. help='Nickname of the account to use')
  91. parser.add_argument('--fol','--follow', dest='follow', type=str,default=None, \
  92. help='Handle of account to follow. eg. nickname@domain')
  93. parser.add_argument('--unfol','--unfollow', dest='unfollow', type=str,default=None, \
  94. help='Handle of account stop following. eg. nickname@domain')
  95. parser.add_argument('-d','--domain', dest='domain', type=str,default=None, \
  96. help='Domain name of the server')
  97. parser.add_argument('-p','--port', dest='port', type=int,default=None, \
  98. help='Port number to run on')
  99. parser.add_argument('--proxy', dest='proxyPort', type=int,default=None, \
  100. help='Proxy port number to run on')
  101. parser.add_argument('--path', dest='baseDir', \
  102. type=str,default=os.getcwd(), \
  103. help='Directory in which to store posts')
  104. parser.add_argument('-a','--addaccount', dest='addaccount', \
  105. type=str,default=None, \
  106. help='Adds a new account')
  107. parser.add_argument('-r','--rmaccount', dest='rmaccount', \
  108. type=str,default=None, \
  109. help='Remove an account')
  110. parser.add_argument('--pass','--password', dest='password', \
  111. type=str,default=None, \
  112. help='Set a password for an account')
  113. parser.add_argument('--chpass','--changepassword', \
  114. nargs='+',dest='changepassword', \
  115. help='Change the password for an account')
  116. parser.add_argument('--actor', dest='actor', type=str,default=None, \
  117. help='Show the json actor the given handle')
  118. parser.add_argument('--posts', dest='posts', type=str,default=None, \
  119. help='Show posts for the given handle')
  120. parser.add_argument('--postsraw', dest='postsraw', type=str,default=None, \
  121. help='Show raw json of posts for the given handle')
  122. parser.add_argument('--json', dest='json', type=str,default=None, \
  123. help='Show the json for a given activitypub url')
  124. parser.add_argument('-f','--federate', nargs='+',dest='federationList', \
  125. help='Specify federation list separated by spaces')
  126. parser.add_argument("--debug", type=str2bool, nargs='?', \
  127. const=True, default=False, \
  128. help="Show debug messages")
  129. parser.add_argument("--http", type=str2bool, nargs='?', \
  130. const=True, default=False, \
  131. help="Use http only")
  132. parser.add_argument("--dat", type=str2bool, nargs='?', \
  133. const=True, default=False, \
  134. help="Use dat protocol only")
  135. parser.add_argument("--tor", type=str2bool, nargs='?', \
  136. const=True, default=False, \
  137. help="Route via Tor")
  138. parser.add_argument("--tests", type=str2bool, nargs='?', \
  139. const=True, default=False, \
  140. help="Run unit tests")
  141. parser.add_argument("--testsnetwork", type=str2bool, nargs='?', \
  142. const=True, default=False, \
  143. help="Run network unit tests")
  144. parser.add_argument("--testdata", type=str2bool, nargs='?', \
  145. const=True, default=False, \
  146. help="Generate some data for testing purposes")
  147. parser.add_argument("--ocap", type=str2bool, nargs='?', \
  148. const=True, default=False, \
  149. help="Always strictly enforce object capabilities")
  150. parser.add_argument("--noreply", type=str2bool, nargs='?', \
  151. const=True, default=False, \
  152. help="Default capabilities don't allow replies on posts")
  153. parser.add_argument("--nolike", type=str2bool, nargs='?', \
  154. const=True, default=False, \
  155. help="Default capabilities don't allow likes/favourites on posts")
  156. parser.add_argument("--nopics", type=str2bool, nargs='?', \
  157. const=True, default=False, \
  158. help="Default capabilities don't allow attached pictures")
  159. parser.add_argument("--noannounce","--norepeat", type=str2bool, nargs='?', \
  160. const=True, default=False, \
  161. help="Default capabilities don't allow announce/repeat")
  162. parser.add_argument("--cw", type=str2bool, nargs='?', \
  163. const=True, default=False, \
  164. help="Default capabilities don't allow posts without content warnings")
  165. parser.add_argument('--icon','--avatar', dest='avatar', type=str,default=None, \
  166. help='Set the avatar filename for an account')
  167. parser.add_argument('--image','--background', dest='backgroundImage', type=str,default=None, \
  168. help='Set the profile background image for an account')
  169. parser.add_argument('--archive', dest='archive', type=str,default=None, \
  170. help='Archive old files to the given directory')
  171. parser.add_argument('--archiveweeks', dest='archiveWeeks', type=str,default=None, \
  172. help='Specify the number of weeks after which data will be archived')
  173. parser.add_argument('--maxposts', dest='archiveMaxPosts', type=str,default=None, \
  174. help='Maximum number of posts in in/outbox')
  175. parser.add_argument('--message', dest='message', type=str,default=None, \
  176. help='Message content')
  177. parser.add_argument('--delete', dest='delete', type=str,default=None, \
  178. help='Delete a specified post')
  179. parser.add_argument("--allowdeletion", type=str2bool, nargs='?', \
  180. const=True, default=False, \
  181. help="Do not allow deletions")
  182. parser.add_argument('--repeat','--announce', dest='announce', type=str,default=None, \
  183. help='Announce/repeat a url')
  184. parser.add_argument('--favorite','--like', dest='like', type=str,default=None, \
  185. help='Like a url')
  186. parser.add_argument('--undolike','--unlike', dest='undolike', type=str,default=None, \
  187. help='Undo a like of a url')
  188. parser.add_argument('--sendto', dest='sendto', type=str,default=None, \
  189. help='Address to send a post to')
  190. parser.add_argument('--attach', dest='attach', type=str,default=None, \
  191. help='File to attach to a post')
  192. parser.add_argument('--imagedescription', dest='imageDescription', type=str,default=None, \
  193. help='Description of an attached image')
  194. parser.add_argument("--blurhash", type=str2bool, nargs='?', \
  195. const=True, default=False, \
  196. help="Create blurhash for an image")
  197. parser.add_argument('--warning','--warn','--cwsubject','--subject', dest='subject', type=str,default=None, \
  198. help='Subject of content warning')
  199. parser.add_argument('--reply','--replyto', dest='replyto', type=str,default=None, \
  200. help='Url of post to reply to')
  201. parser.add_argument("--followersonly", type=str2bool, nargs='?', \
  202. const=True, default=True, \
  203. help="Send to followers only")
  204. parser.add_argument("--followerspending", type=str2bool, nargs='?', \
  205. const=True, default=False, \
  206. help="Show a list of followers pending")
  207. parser.add_argument('--approve', dest='approve', type=str,default=None, \
  208. help='Approve a follow request')
  209. parser.add_argument('--deny', dest='deny', type=str,default=None, \
  210. help='Deny a follow request')
  211. parser.add_argument("-c","--client", type=str2bool, nargs='?', \
  212. const=True, default=False, \
  213. help="Use as an ActivityPub client")
  214. parser.add_argument('--maxreplies', dest='maxReplies', type=int,default=64, \
  215. help='Maximum number of replies to a post')
  216. parser.add_argument('--role', dest='role', type=str,default=None, \
  217. help='Set a role for a person')
  218. parser.add_argument('--organization','--project', dest='project', type=str,default=None, \
  219. help='Set a project for a person')
  220. parser.add_argument('--skill', dest='skill', type=str,default=None, \
  221. help='Set a skill for a person')
  222. parser.add_argument('--level', dest='skillLevelPercent', type=int,default=None, \
  223. help='Set a skill level for a person as a percentage, or zero to remove')
  224. parser.add_argument('--status','--availability', dest='availability', type=str,default=None, \
  225. help='Set an availability status')
  226. parser.add_argument('--block', dest='block', type=str,default=None, \
  227. help='Block a particular address')
  228. parser.add_argument('--unblock', dest='unblock', type=str,default=None, \
  229. help='Remove a block on a particular address')
  230. parser.add_argument('--delegate', dest='delegate', type=str,default=None, \
  231. help='Address of an account to delegate a role to')
  232. parser.add_argument('--undodelegate','--undelegate', dest='undelegate', type=str,default=None, \
  233. help='Removes a delegated role for the given address')
  234. parser.add_argument('--filter', dest='filterStr', type=str,default=None, \
  235. help='Adds a word or phrase which if present will cause a message to be ignored')
  236. parser.add_argument('--unfilter', dest='unfilterStr', type=str,default=None, \
  237. help='Remove a filter on a particular word or phrase')
  238. parser.add_argument('--domainmax', dest='domainMaxPostsPerDay', type=int,default=8640, \
  239. help='Maximum number of received posts from a domain per day')
  240. parser.add_argument('--accountmax', dest='accountMaxPostsPerDay', type=int,default=8640, \
  241. help='Maximum number of received posts from an account per day')
  242. parser.add_argument('--itemName', dest='itemName', type=str,default=None, \
  243. help='Name of an item being shared')
  244. parser.add_argument('--undoItemName', dest='undoItemName', type=str,default=None, \
  245. help='Name of an shared item to remove')
  246. parser.add_argument('--summary', dest='summary', type=str,default=None, \
  247. help='Description of an item being shared')
  248. parser.add_argument('--itemImage', dest='itemImage', type=str,default=None, \
  249. help='Filename of an image for an item being shared')
  250. parser.add_argument('--itemType', dest='itemType', type=str,default=None, \
  251. help='Type of item being shared')
  252. parser.add_argument('--itemCategory', dest='itemCategory', type=str,default=None, \
  253. help='Category of item being shared')
  254. parser.add_argument('--location', dest='location', type=str,default=None, \
  255. help='Location/City of item being shared')
  256. parser.add_argument('--duration', dest='duration', type=str,default=None, \
  257. help='Duration for which to share an item')
  258. parser.add_argument('--registration', dest='registration', type=str,default=None, \
  259. help='Whether new registrations are open or closed')
  260. parser.add_argument('--maxregistrations', dest='maxRegistrations', type=int,default=None, \
  261. help='The maximum number of new registrations')
  262. parser.add_argument("--resetregistrations", type=str2bool, nargs='?', \
  263. const=True, default=False, \
  264. help="Reset the number of remaining registrations")
  265. args = parser.parse_args()
  266. debug=False
  267. if args.debug:
  268. debug=True
  269. if args.tests:
  270. runAllTests()
  271. sys.exit()
  272. if args.testsnetwork:
  273. print('Network Tests')
  274. testPostMessageBetweenServers()
  275. testFollowBetweenServers()
  276. testClientToServer()
  277. print('All tests succeeded')
  278. sys.exit()
  279. httpPrefix='https'
  280. if args.http:
  281. httpPrefix='http'
  282. if args.posts:
  283. if '@' not in args.posts:
  284. print('Syntax: --posts nickname@domain')
  285. sys.exit()
  286. if not args.http:
  287. args.port=443
  288. nickname=args.posts.split('@')[0]
  289. domain=args.posts.split('@')[1]
  290. getPublicPostsOfPerson(nickname,domain,False,True, \
  291. args.tor,args.port,httpPrefix,debug, \
  292. __version__)
  293. sys.exit()
  294. if args.postsraw:
  295. if '@' not in args.postsraw:
  296. print('Syntax: --postsraw nickname@domain')
  297. sys.exit()
  298. if not args.http:
  299. args.port=443
  300. nickname=args.postsraw.split('@')[0]
  301. domain=args.postsraw.split('@')[1]
  302. getPublicPostsOfPerson(nickname,domain,False,False, \
  303. args.tor,args.port,httpPrefix,debug, \
  304. __version__)
  305. sys.exit()
  306. baseDir=args.baseDir
  307. if baseDir.endswith('/'):
  308. print("--path option should not end with '/'")
  309. sys.exit()
  310. if args.domain:
  311. domain=args.domain
  312. setConfigParam(baseDir,'domain',domain)
  313. # maximum number of new registrations
  314. if not args.maxRegistrations:
  315. maxRegistrations=getConfigParam(baseDir,'maxRegistrations')
  316. if not maxRegistrations:
  317. maxRegistrations=10
  318. setConfigParam(baseDir,'maxRegistrations',str(maxRegistrations))
  319. else:
  320. maxRegistrations=int(maxRegistrations)
  321. else:
  322. maxRegistrations=args.maxRegistrations
  323. setConfigParam(baseDir,'maxRegistrations',str(maxRegistrations))
  324. # if this is the initial run then allow new registrations
  325. if not getConfigParam(baseDir,'registration'):
  326. setConfigParam(baseDir,'registration','open')
  327. setConfigParam(baseDir,'maxRegistrations',str(maxRegistrations))
  328. setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
  329. if args.resetregistrations:
  330. setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
  331. print('Number of new registrations reset to '+str(maxRegistrations))
  332. # whether new registrations are open or closed
  333. if args.registration:
  334. if args.registration.lower()=='open':
  335. registration=getConfigParam(baseDir,'registration')
  336. if not registration:
  337. setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
  338. else:
  339. if registration!='open':
  340. setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
  341. setConfigParam(baseDir,'registration','open')
  342. print('New registrations open')
  343. else:
  344. setConfigParam(baseDir,'registration','closed')
  345. print('New registrations closed')
  346. # unique ID for the instance
  347. instanceId=getConfigParam(baseDir,'instanceId')
  348. if not instanceId:
  349. instanceId=createPassword(32)
  350. setConfigParam(baseDir,'instanceId',instanceId)
  351. print('Instance ID: '+instanceId)
  352. # get domain name from configuration
  353. configDomain=getConfigParam(baseDir,'domain')
  354. if configDomain:
  355. domain=configDomain
  356. else:
  357. domain='localhost'
  358. # get port number from configuration
  359. configPort=getConfigParam(baseDir,'port')
  360. if configPort:
  361. port=configPort
  362. else:
  363. port=8085
  364. configProxyPort=getConfigParam(baseDir,'proxyPort')
  365. if configProxyPort:
  366. proxyPort=configProxyPort
  367. else:
  368. proxyPort=port
  369. nickname=None
  370. if args.nickname:
  371. nickname=nickname
  372. federationList=[]
  373. if args.federationList:
  374. if len(args.federationList)==1:
  375. if not (args.federationList[0].lower()=='any' or \
  376. args.federationList[0].lower()=='all' or \
  377. args.federationList[0].lower()=='*'):
  378. for federationDomain in args.federationList:
  379. if '@' in federationDomain:
  380. print(federationDomain+': Federate with domains, not individual accounts')
  381. sys.exit()
  382. federationList=args.federationList.copy()
  383. setConfigParam(baseDir,'federationList',federationList)
  384. else:
  385. configFederationList=getConfigParam(baseDir,'federationList')
  386. if configFederationList:
  387. federationList=configFederationList
  388. useTor=args.tor
  389. if domain.endswith('.onion'):
  390. useTor=True
  391. if args.approve:
  392. if not args.nickname:
  393. print('Specify a nickname with the --nickname option')
  394. sys.exit()
  395. if '@' not in args.approve:
  396. print('syntax: --approve nick@domain')
  397. sys.exit()
  398. sendThreads=[]
  399. postLog=[]
  400. cachedWebfingers={}
  401. personCache={}
  402. acceptedCaps=[]
  403. manualApproveFollowRequest(session,baseDir, \
  404. httpPrefix,
  405. args.nickname,domain,port, \
  406. args.approve, \
  407. federationList, \
  408. sendThreads,postLog, \
  409. cachedWebfingers,personCache, \
  410. acceptedCaps, \
  411. debug,__version__)
  412. sys.exit()
  413. if args.deny:
  414. if not args.nickname:
  415. print('Specify a nickname with the --nickname option')
  416. sys.exit()
  417. if '@' not in args.deny:
  418. print('syntax: --deny nick@domain')
  419. sys.exit()
  420. manualDenyFollowRequest(baseDir,args.nickname,domain,args.deny)
  421. sys.exit()
  422. if args.followerspending:
  423. if not args.nickname:
  424. print('Specify a nickname with the --nickname option')
  425. sys.exit()
  426. accountsDir=baseDir+'/accounts/'+args.nickname+'@'+domain
  427. approveFollowsFilename=accountsDir+'/followrequests.txt'
  428. approveCtr=0
  429. if os.path.isfile(approveFollowsFilename):
  430. with open(approveFollowsFilename, 'r') as approvefile:
  431. for approve in approvefile:
  432. print(approve.replace('\n',''))
  433. approveCtr+=1
  434. if approveCtr==0:
  435. print('There are no follow requests pending approval.')
  436. sys.exit()
  437. if args.message:
  438. if not args.nickname:
  439. print('Specify a nickname with the --nickname option')
  440. sys.exit()
  441. if not args.password:
  442. print('Specify a password with the --password option')
  443. sys.exit()
  444. session = createSession(domain,port,useTor)
  445. if not args.sendto:
  446. print('Specify an account to sent to: --sendto [nickname@domain]')
  447. sys.exit()
  448. if '@' not in args.sendto and \
  449. not args.sendto.lower().endswith('public') and \
  450. not args.sendto.lower().endswith('followers'):
  451. print('syntax: --sendto [nickname@domain]')
  452. print(' --sendto public')
  453. print(' --sendto followers')
  454. sys.exit()
  455. if '@' in args.sendto:
  456. toNickname=args.sendto.split('@')[0]
  457. toDomain=args.sendto.split('@')[1].replace('\n','')
  458. toPort=443
  459. if ':' in toDomain:
  460. toPort=toDomain.split(':')[1]
  461. toDomain=toDomain.split(':')[0]
  462. else:
  463. if args.sendto.endswith('followers'):
  464. toNickname=None
  465. toDomain='followers'
  466. toPort=port
  467. else:
  468. toNickname=None
  469. toDomain='public'
  470. toPort=port
  471. #ccUrl=httpPrefix+'://'+domain+'/users/'+nickname+'/followers'
  472. ccUrl=None
  473. sendMessage=args.message
  474. followersOnly=args.followersonly
  475. clientToServer=args.client
  476. attachedImageDescription=args.imageDescription
  477. useBlurhash=args.blurhash
  478. sendThreads = []
  479. postLog = []
  480. personCache={}
  481. cachedWebfingers={}
  482. subject=args.subject
  483. attach=args.attach
  484. replyTo=args.replyto
  485. followersOnly=False
  486. print('Sending post to '+args.sendto)
  487. sendPostViaServer(__version__, \
  488. baseDir,session,args.nickname,args.password, \
  489. domain,port, \
  490. toNickname,toDomain,toPort,ccUrl, \
  491. httpPrefix,sendMessage,followersOnly, \
  492. attach,attachedImageDescription,useBlurhash, \
  493. cachedWebfingers,personCache, \
  494. args.debug,replyTo,replyTo,subject)
  495. for i in range(10):
  496. # TODO detect send success/fail
  497. time.sleep(1)
  498. sys.exit()
  499. if args.announce:
  500. if not args.nickname:
  501. print('Specify a nickname with the --nickname option')
  502. sys.exit()
  503. if not args.password:
  504. print('Specify a password with the --password option')
  505. sys.exit()
  506. session = createSession(domain,port,useTor)
  507. personCache={}
  508. cachedWebfingers={}
  509. print('Sending announce/repeat of '+args.announce)
  510. sendAnnounceViaServer(session,args.nickname,args.password,
  511. domain,port, \
  512. httpPrefix,args.announce, \
  513. cachedWebfingers,personCache, \
  514. True,__version__)
  515. for i in range(10):
  516. # TODO detect send success/fail
  517. time.sleep(1)
  518. sys.exit()
  519. if args.itemName:
  520. if not args.password:
  521. print('Specify a password with the --password option')
  522. sys.exit()
  523. if not args.nickname:
  524. print('Specify a nickname with the --nickname option')
  525. sys.exit()
  526. if not args.summary:
  527. print('Specify a description for your shared item with the --summary option')
  528. sys.exit()
  529. if not args.itemType:
  530. print('Specify a type of shared item with the --itemType option')
  531. sys.exit()
  532. if not args.itemCategory:
  533. print('Specify a category of shared item with the --itemCategory option')
  534. sys.exit()
  535. if not args.location:
  536. print('Specify a location or city where theshared item resides with the --location option')
  537. sys.exit()
  538. if not args.duration:
  539. print('Specify a duration to share the object with the --duration option')
  540. sys.exit()
  541. session = createSession(domain,port,useTor)
  542. personCache={}
  543. cachedWebfingers={}
  544. print('Sending shared item: '+args.itemName)
  545. sendShareViaServer(session, \
  546. args.nickname,args.password, \
  547. domain,port, \
  548. httpPrefix, \
  549. args.itemName, \
  550. args.summary, \
  551. args.itemImage, \
  552. args.itemType, \
  553. args.itemCategory, \
  554. args.location, \
  555. args.duration, \
  556. cachedWebfingers,personCache, \
  557. debug,__version__)
  558. for i in range(10):
  559. # TODO detect send success/fail
  560. time.sleep(1)
  561. sys.exit()
  562. if args.undoItemName:
  563. if not args.password:
  564. print('Specify a password with the --password option')
  565. sys.exit()
  566. if not args.nickname:
  567. print('Specify a nickname with the --nickname option')
  568. sys.exit()
  569. session = createSession(domain,port,useTor)
  570. personCache={}
  571. cachedWebfingers={}
  572. print('Sending undo of shared item: '+args.undoItemName)
  573. sendUndoShareViaServer(session, \
  574. args.nickname,args.password, \
  575. domain,port, \
  576. httpPrefix, \
  577. args.undoItemName, \
  578. cachedWebfingers,personCache, \
  579. debug,__version__)
  580. for i in range(10):
  581. # TODO detect send success/fail
  582. time.sleep(1)
  583. sys.exit()
  584. if args.like:
  585. if not args.nickname:
  586. print('Specify a nickname with the --nickname option')
  587. sys.exit()
  588. if not args.password:
  589. print('Specify a password with the --password option')
  590. sys.exit()
  591. session = createSession(domain,port,useTor)
  592. personCache={}
  593. cachedWebfingers={}
  594. print('Sending like of '+args.like)
  595. sendLikeViaServer(session,args.nickname,args.password,
  596. domain,port, \
  597. httpPrefix,args.like, \
  598. cachedWebfingers,personCache, \
  599. True,__version__)
  600. for i in range(10):
  601. # TODO detect send success/fail
  602. time.sleep(1)
  603. sys.exit()
  604. if args.undolike:
  605. if not args.nickname:
  606. print('Specify a nickname with the --nickname option')
  607. sys.exit()
  608. if not args.password:
  609. print('Specify a password with the --password option')
  610. sys.exit()
  611. session = createSession(domain,port,useTor)
  612. personCache={}
  613. cachedWebfingers={}
  614. print('Sending undo like of '+args.undolike)
  615. sendUndoLikeViaServer(session,args.nickname,args.password,
  616. domain,port, \
  617. httpPrefix,args.undolike, \
  618. cachedWebfingers,personCache, \
  619. True,__version__)
  620. for i in range(10):
  621. # TODO detect send success/fail
  622. time.sleep(1)
  623. sys.exit()
  624. if args.delete:
  625. if not args.nickname:
  626. print('Specify a nickname with the --nickname option')
  627. sys.exit()
  628. if not args.password:
  629. print('Specify a password with the --password option')
  630. sys.exit()
  631. session = createSession(domain,port,useTor)
  632. personCache={}
  633. cachedWebfingers={}
  634. print('Sending delete request of '+args.delete)
  635. sendDeleteViaServer(session,args.nickname,args.password,
  636. domain,port, \
  637. httpPrefix,args.delete, \
  638. cachedWebfingers,personCache, \
  639. True,__version__)
  640. for i in range(10):
  641. # TODO detect send success/fail
  642. time.sleep(1)
  643. sys.exit()
  644. if args.follow:
  645. # follow via c2s protocol
  646. if '.' not in args.follow:
  647. print("This doesn't look like a fediverse handle")
  648. sys.exit()
  649. if not args.nickname:
  650. print('Please specify the nickname for the account with --nickname')
  651. sys.exit()
  652. if not args.password:
  653. print('Please specify the password for '+args.nickname+' on '+domain)
  654. sys.exit()
  655. followNickname=getNicknameFromActor(args.follow)
  656. followDomain,followPort=getDomainFromActor(args.follow)
  657. session = createSession(domain,port,useTor)
  658. personCache={}
  659. cachedWebfingers={}
  660. followHttpPrefix=httpPrefix
  661. if args.follow.startswith('https'):
  662. followHttpPrefix='https'
  663. sendFollowRequestViaServer(session,args.nickname,args.password, \
  664. domain,port, \
  665. followNickname,followDomain,followPort, \
  666. httpPrefix, \
  667. cachedWebfingers,personCache, \
  668. debug,__version__)
  669. for t in range(20):
  670. time.sleep(1)
  671. # TODO some method to know if it worked
  672. print('Ok')
  673. sys.exit()
  674. if args.unfollow:
  675. # unfollow via c2s protocol
  676. if '.' not in args.follow:
  677. print("This doesn't look like a fediverse handle")
  678. sys.exit()
  679. if not args.nickname:
  680. print('Please specify the nickname for the account with --nickname')
  681. sys.exit()
  682. if not args.password:
  683. print('Please specify the password for '+args.nickname+' on '+domain)
  684. sys.exit()
  685. followNickname=getNicknameFromActor(args.unfollow)
  686. followDomain,followPort=getDomainFromActor(args.unfollow)
  687. session = createSession(domain,port,useTor)
  688. personCache={}
  689. cachedWebfingers={}
  690. followHttpPrefix=httpPrefix
  691. if args.follow.startswith('https'):
  692. followHttpPrefix='https'
  693. sendUnfollowRequestViaServer(session,args.nickname,args.password, \
  694. domain,port, \
  695. followNickname,followDomain,followPort, \
  696. httpPrefix, \
  697. cachedWebfingers,personCache, \
  698. debug,__version__)
  699. for t in range(20):
  700. time.sleep(1)
  701. # TODO some method to know if it worked
  702. print('Ok')
  703. sys.exit()
  704. nickname='admin'
  705. if args.domain:
  706. domain=args.domain
  707. setConfigParam(baseDir,'domain',domain)
  708. if args.port:
  709. port=args.port
  710. setConfigParam(baseDir,'port',port)
  711. if args.proxyPort:
  712. proxyPort=args.proxyPort
  713. setConfigParam(baseDir,'proxyPort',proxyPort)
  714. ocapAlways=False
  715. if args.ocap:
  716. ocapAlways=args.ocap
  717. if args.dat:
  718. httpPrefix='dat'
  719. if args.actor:
  720. if '@' not in args.actor:
  721. print('Syntax: --actor nickname@domain')
  722. sys.exit()
  723. nickname=args.actor.split('@')[0]
  724. domain=args.actor.split('@')[1].replace('\n','')
  725. wfCache={}
  726. if args.http or domain.endswith('.onion'):
  727. httpPrefix='http'
  728. port=80
  729. else:
  730. httpPrefix='https'
  731. port=443
  732. session = createSession(domain,port,useTor)
  733. wfRequest = webfingerHandle(session,nickname+'@'+domain,httpPrefix,wfCache, \
  734. domain,__version__)
  735. if not wfRequest:
  736. print('Unable to webfinger '+nickname+'@'+domain)
  737. sys.exit()
  738. asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
  739. personUrl = getUserUrl(wfRequest)
  740. personJson = getJson(session,personUrl,asHeader,None,__version__,httpPrefix,domain)
  741. if personJson:
  742. pprint(personJson)
  743. else:
  744. print('Failed to get '+personUrl)
  745. sys.exit()
  746. if args.json:
  747. session = createSession(domain,port,True)
  748. asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
  749. testJson = getJson(session,args.json,asHeader,None,__version__,httpPrefix,domain)
  750. pprint(testJson)
  751. sys.exit()
  752. if args.addaccount:
  753. if '@' in args.addaccount:
  754. nickname=args.addaccount.split('@')[0]
  755. domain=args.addaccount.split('@')[1]
  756. else:
  757. nickname=args.addaccount
  758. if not args.domain or not getConfigParam(baseDir,'domain'):
  759. print('Use the --domain option to set the domain name')
  760. sys.exit()
  761. if not validNickname(nickname):
  762. print(nickname+' is a reserved name. Use something different.')
  763. sys.exit()
  764. if not args.password:
  765. print('Use the --password option to set the password for '+nickname)
  766. sys.exit()
  767. if len(args.password.strip())<8:
  768. print('Password should be at least 8 characters')
  769. sys.exit()
  770. if os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
  771. print('Account already exists')
  772. sys.exit()
  773. createPerson(baseDir,nickname,domain,port,httpPrefix,True,args.password.strip())
  774. if os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
  775. print('Account created for '+nickname+'@'+domain)
  776. else:
  777. print('Account creation failed')
  778. sys.exit()
  779. if args.rmaccount:
  780. if '@' in args.rmaccount:
  781. nickname=args.rmaccount.split('@')[0]
  782. domain=args.rmaccount.split('@')[1]
  783. else:
  784. nickname=args.rmaccount
  785. if not args.domain or not getConfigParam(baseDir,'domain'):
  786. print('Use the --domain option to set the domain name')
  787. sys.exit()
  788. if removeAccount(baseDir,nickname,domain,port):
  789. print('Account for '+handle+' was removed')
  790. sys.exit()
  791. if args.changepassword:
  792. if len(args.changepassword)!=2:
  793. print('--changepassword [nickname] [new password]')
  794. sys.exit()
  795. if '@' in args.changepassword[0]:
  796. nickname=args.changepassword[0].split('@')[0]
  797. domain=args.changepassword[0].split('@')[1]
  798. else:
  799. nickname=args.changepassword[0]
  800. if not args.domain or not getConfigParam(baseDir,'domain'):
  801. print('Use the --domain option to set the domain name')
  802. sys.exit()
  803. newPassword=args.changepassword[1]
  804. if len(newPassword)<8:
  805. print('Password should be at least 8 characters')
  806. sys.exit()
  807. if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
  808. print('Account '+nickname+'@'+domain+' not found')
  809. sys.exit()
  810. passwordFile=baseDir+'/accounts/passwords'
  811. if os.path.isfile(passwordFile):
  812. if nickname+':' in open(passwordFile).read():
  813. storeBasicCredentials(baseDir,nickname,newPassword)
  814. print('Password for '+nickname+' was changed')
  815. else:
  816. print(nickname+' is not in the passwords file')
  817. else:
  818. print('Passwords file not found')
  819. sys.exit()
  820. archiveWeeks=4
  821. if args.archiveWeeks:
  822. archiveWeeks=args.archiveWeeks
  823. archiveMaxPosts=256
  824. if args.archiveMaxPosts:
  825. archiveMaxPosts=args.archiveMaxPosts
  826. if args.archive:
  827. if args.archive.lower().endswith('null') or \
  828. args.archive.lower().endswith('delete') or \
  829. args.archive.lower().endswith('none'):
  830. args.archive=None
  831. print('Archiving with deletion of old posts...')
  832. else:
  833. print('Archiving to '+args.archive+'...')
  834. archiveMedia(baseDir,args.archive,archiveWeeks)
  835. archivePosts(baseDir,httpPrefix,args.archive,archiveMaxPosts)
  836. print('Archiving complete')
  837. sys.exit()
  838. if not args.domain and not domain:
  839. print('Specify a domain with --domain [name]')
  840. sys.exit()
  841. if args.avatar:
  842. if not os.path.isfile(args.avatar):
  843. print(args.avatar+' is not an image filename')
  844. sys.exit()
  845. if not args.nickname:
  846. print('Specify a nickname with --nickname [name]')
  847. sys.exit()
  848. if setProfileImage(baseDir,httpPrefix,args.nickname,domain, \
  849. port,args.avatar,'avatar','128x128'):
  850. print('Avatar added for '+args.nickname)
  851. else:
  852. print('Avatar was not added for '+args.nickname)
  853. sys.exit()
  854. if args.backgroundImage:
  855. if not os.path.isfile(args.backgroundImage):
  856. print(args.backgroundImage+' is not an image filename')
  857. sys.exit()
  858. if not args.nickname:
  859. print('Specify a nickname with --nickname [name]')
  860. sys.exit()
  861. if setProfileImage(baseDir,httpPrefix,args.nickname,domain, \
  862. port,args.backgroundImage,'background','256x256'):
  863. print('Background image added for '+args.nickname)
  864. else:
  865. print('Background image was not added for '+args.nickname)
  866. sys.exit()
  867. if args.project:
  868. if not args.delegate and not args.undelegate:
  869. if not nickname:
  870. print('No nickname given')
  871. sys.exit()
  872. if args.role.lower()=='none' or \
  873. args.role.lower()=='remove' or \
  874. args.role.lower()=='delete':
  875. args.role=None
  876. if args.role:
  877. if setRole(baseDir,nickname,domain,args.project,args.role):
  878. print('Role within '+args.project+' set to '+args.role)
  879. else:
  880. if setRole(baseDir,nickname,domain,args.project,None):
  881. print('Left '+args.project)
  882. sys.exit()
  883. if args.skill:
  884. if not nickname:
  885. print('Specify a nickname with the --nickname option')
  886. sys.exit()
  887. if not args.password:
  888. print('Specify a password with the --password option')
  889. sys.exit()
  890. if not args.skillLevelPercent:
  891. print('Specify a skill level in the range 0-100')
  892. sys.exit()
  893. if int(args.skillLevelPercent)<0 or int(args.skillLevelPercent)>100:
  894. print('Skill level should be a percentage in the range 0-100')
  895. sys.exit()
  896. session = createSession(domain,port,useTor)
  897. personCache={}
  898. cachedWebfingers={}
  899. print('Sending '+args.skill+' skill level '+str(args.skillLevelPercent)+' for '+nickname)
  900. sendSkillViaServer(session,nickname,args.password,
  901. domain,port, \
  902. httpPrefix, \
  903. args.skill,args.skillLevelPercent, \
  904. cachedWebfingers,personCache, \
  905. True,__version__)
  906. for i in range(10):
  907. # TODO detect send success/fail
  908. time.sleep(1)
  909. sys.exit()
  910. if args.availability:
  911. if not nickname:
  912. print('Specify a nickname with the --nickname option')
  913. sys.exit()
  914. if not args.password:
  915. print('Specify a password with the --password option')
  916. sys.exit()
  917. session = createSession(domain,port,useTor)
  918. personCache={}
  919. cachedWebfingers={}
  920. print('Sending availability status of '+nickname+' as '+args.availability)
  921. sendAvailabilityViaServer(session,nickname,args.password,
  922. domain,port, \
  923. httpPrefix, \
  924. args.availability, \
  925. cachedWebfingers,personCache, \
  926. True,__version__)
  927. for i in range(10):
  928. # TODO detect send success/fail
  929. time.sleep(1)
  930. sys.exit()
  931. if federationList:
  932. print('Federating with: '+str(federationList))
  933. #if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
  934. # print('Creating default admin account '+nickname+'@'+domain)
  935. # print('See config.json for the password. You can remove the password from config.json after moving it elsewhere.')
  936. # adminPassword=createPassword(10)
  937. # setConfigParam(baseDir,'adminPassword',adminPassword)
  938. # createPerson(baseDir,nickname,domain,port,httpPrefix,True,adminPassword)
  939. if args.block:
  940. if not nickname:
  941. print('Specify a nickname with the --nickname option')
  942. sys.exit()
  943. if not args.password:
  944. print('Specify a password with the --password option')
  945. sys.exit()
  946. if '@' in args.block:
  947. blockedDomain=args.block.split('@')[1].replace('\n','')
  948. blockedNickname=args.block.split('@')[0]
  949. blockedActor=httpPrefix+'://'+blockedDomain+'/users/'+blockedNickname
  950. args.block=blockedActor
  951. else:
  952. if '/users/' not in args.block:
  953. print(args.block+' does not look like an actor url')
  954. sys.exit()
  955. session = createSession(domain,port,useTor)
  956. personCache={}
  957. cachedWebfingers={}
  958. print('Sending block of '+args.block)
  959. sendBlockViaServer(session,nickname,args.password,
  960. domain,port, \
  961. httpPrefix,args.block, \
  962. cachedWebfingers,personCache, \
  963. True,__version__)
  964. for i in range(10):
  965. # TODO detect send success/fail
  966. time.sleep(1)
  967. sys.exit()
  968. if args.delegate:
  969. if not nickname:
  970. print('Specify a nickname with the --nickname option')
  971. sys.exit()
  972. if not args.password:
  973. print('Specify a password with the --password option')
  974. sys.exit()
  975. if not args.project:
  976. print('Specify a project with the --project option')
  977. sys.exit()
  978. if not args.role:
  979. print('Specify a role with the --role option')
  980. sys.exit()
  981. if '@' in args.delegate:
  982. delegatedNickname=args.delegate.split('@')[0]
  983. args.delegate=blockedActor
  984. session = createSession(domain,port,useTor)
  985. personCache={}
  986. cachedWebfingers={}
  987. print('Sending delegation for '+args.delegate+' with role '+args.role+' in project '+args.project)
  988. sendRoleViaServer(session,nickname,args.password,
  989. domain,port, \
  990. httpPrefix,args.delegate, \
  991. args.project,args.role, \
  992. cachedWebfingers,personCache, \
  993. True,__version__)
  994. for i in range(10):
  995. # TODO detect send success/fail
  996. time.sleep(1)
  997. sys.exit()
  998. if args.undelegate:
  999. if not nickname:
  1000. print('Specify a nickname with the --nickname option')
  1001. sys.exit()
  1002. if not args.password:
  1003. print('Specify a password with the --password option')
  1004. sys.exit()
  1005. if not args.project:
  1006. print('Specify a project with the --project option')
  1007. sys.exit()
  1008. if '@' in args.undelegate:
  1009. delegatedNickname=args.undelegate.split('@')[0]
  1010. args.undelegate=blockedActor
  1011. session = createSession(domain,port,useTor)
  1012. personCache={}
  1013. cachedWebfingers={}
  1014. print('Sending delegation removal for '+args.undelegate+' from role '+args.role+' in project '+args.project)
  1015. sendRoleViaServer(session,nickname,args.password,
  1016. domain,port, \
  1017. httpPrefix,args.delegate, \
  1018. args.project,None, \
  1019. cachedWebfingers,personCache, \
  1020. True,__version__)
  1021. for i in range(10):
  1022. # TODO detect send success/fail
  1023. time.sleep(1)
  1024. sys.exit()
  1025. if args.unblock:
  1026. if not nickname:
  1027. print('Specify a nickname with the --nickname option')
  1028. sys.exit()
  1029. if not args.password:
  1030. print('Specify a password with the --password option')
  1031. sys.exit()
  1032. if '@' in args.unblock:
  1033. blockedDomain=args.unblock.split('@')[1].replace('\n','')
  1034. blockedNickname=args.unblock.split('@')[0]
  1035. blockedActor=httpPrefix+'://'+blockedDomain+'/users/'+blockedNickname
  1036. args.unblock=blockedActor
  1037. else:
  1038. if '/users/' not in args.unblock:
  1039. print(args.unblock+' does not look like an actor url')
  1040. sys.exit()
  1041. session = createSession(domain,port,useTor)
  1042. personCache={}
  1043. cachedWebfingers={}
  1044. print('Sending undo block of '+args.unblock)
  1045. sendUndoBlockViaServer(session,nickname,args.password,
  1046. domain,port, \
  1047. httpPrefix,args.unblock, \
  1048. cachedWebfingers,personCache, \
  1049. True,__version__)
  1050. for i in range(10):
  1051. # TODO detect send success/fail
  1052. time.sleep(1)
  1053. sys.exit()
  1054. if args.filterStr:
  1055. if not args.nickname:
  1056. print('Please specify a nickname')
  1057. sys.exit()
  1058. if addFilter(baseDir,args.nickname,domain,args.filterStr):
  1059. print('Filter added to '+args.nickname+': '+args.filterStr)
  1060. sys.exit()
  1061. if args.unfilterStr:
  1062. if not args.nickname:
  1063. print('Please specify a nickname')
  1064. sys.exit()
  1065. if removeFilter(baseDir,args.nickname,domain,args.unfilterStr):
  1066. print('Filter removed from '+args.nickname+': '+args.unfilterStr)
  1067. sys.exit()
  1068. if args.testdata:
  1069. useBlurhash=False
  1070. nickname='testuser567'
  1071. password='boringpassword'
  1072. print('Generating some test data for user: '+nickname)
  1073. if os.path.isdir(baseDir+'/tags'):
  1074. shutil.rmtree(baseDir+'/tags')
  1075. if os.path.isdir(baseDir+'/accounts'):
  1076. shutil.rmtree(baseDir+'/accounts')
  1077. if os.path.isdir(baseDir+'/keys'):
  1078. shutil.rmtree(baseDir+'/keys')
  1079. if os.path.isdir(baseDir+'/media'):
  1080. shutil.rmtree(baseDir+'/media')
  1081. if os.path.isdir(baseDir+'/sharefiles'):
  1082. shutil.rmtree(baseDir+'/sharefiles')
  1083. if os.path.isdir(baseDir+'/wfendpoints'):
  1084. shutil.rmtree(baseDir+'/wfendpoints')
  1085. setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
  1086. createPerson(baseDir,'maxboardroom',domain,port,httpPrefix,True,password)
  1087. createPerson(baseDir,'ultrapancake',domain,port,httpPrefix,True,password)
  1088. createPerson(baseDir,'drokk',domain,port,httpPrefix,True,password)
  1089. createPerson(baseDir,'sausagedog',domain,port,httpPrefix,True,password)
  1090. createPerson(baseDir,nickname,domain,port,httpPrefix,True,'likewhateveryouwantscoob')
  1091. setSkillLevel(baseDir,nickname,domain,'testing',60)
  1092. setSkillLevel(baseDir,nickname,domain,'typing',50)
  1093. setRole(baseDir,nickname,domain,'instance','admin')
  1094. setRole(baseDir,nickname,domain,'epicyon','hacker')
  1095. setRole(baseDir,nickname,domain,'someproject','assistant')
  1096. setAvailability(baseDir,nickname,domain,'busy')
  1097. addShare(baseDir, \
  1098. httpPrefix,nickname,domain,port, \
  1099. "spanner", \
  1100. "It's a spanner", \
  1101. "img/shares1.png", \
  1102. "tool", \
  1103. "mechanical", \
  1104. "City", \
  1105. "2 months",
  1106. debug)
  1107. addShare(baseDir, \
  1108. httpPrefix,nickname,domain,port, \
  1109. "witch hat", \
  1110. "Spooky", \
  1111. "img/shares2.png", \
  1112. "hat", \
  1113. "clothing", \
  1114. "City", \
  1115. "3 months",
  1116. debug)
  1117. deleteAllPosts(baseDir,nickname,domain,'inbox')
  1118. deleteAllPosts(baseDir,nickname,domain,'outbox')
  1119. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"like, this is totally just a #test, man",False,True,False,None,None,useBlurhash)
  1120. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"Zoiks!!!",False,True,False,None,None,useBlurhash)
  1121. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"Hey scoob we need like a hundred more #milkshakes",False,True,False,None,None,useBlurhash)
  1122. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"Getting kinda spooky around here",False,True,False,None,None,useBlurhash,'someone')
  1123. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"And they would have gotten away with it too if it wasn't for those pesky hackers",False,True,False,'img/logo.png','Description of image',useBlurhash)
  1124. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"man, these centralized sites are, like, the worst!",False,True,False,None,None,useBlurhash)
  1125. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"another mystery solved #test",False,True,False,None,None,useBlurhash)
  1126. createPublicPost(baseDir,nickname,domain,port,httpPrefix,"let's go bowling",False,True,False,None,None,useBlurhash)
  1127. domainFull=domain+':'+str(port)
  1128. clearFollows(baseDir,nickname,domain)
  1129. followPerson(baseDir,nickname,domain,'maxboardroom',domainFull,federationList,False)
  1130. followPerson(baseDir,nickname,domain,'ultrapancake',domainFull,federationList,False)
  1131. followPerson(baseDir,nickname,domain,'sausagedog',domainFull,federationList,False)
  1132. followPerson(baseDir,nickname,domain,'drokk',domainFull,federationList,False)
  1133. followerOfPerson(baseDir,nickname,domain,'drokk',domainFull,federationList,False)
  1134. followerOfPerson(baseDir,nickname,domain,'maxboardroom',domainFull,federationList,False)
  1135. setConfigParam(baseDir,'admin',nickname)
  1136. runDaemon(__version__, \
  1137. instanceId,args.client,baseDir, \
  1138. domain,port,proxyPort,httpPrefix, \
  1139. federationList, \
  1140. args.noreply,args.nolike,args.nopics, \
  1141. args.noannounce,args.cw,ocapAlways, \
  1142. useTor,args.maxReplies, \
  1143. args.domainMaxPostsPerDay,args.accountMaxPostsPerDay, \
  1144. args.allowdeletion,debug,False)