epicyon/epicyon.py

3461 lines
135 KiB
Python
Raw Normal View History

2020-04-03 10:08:04 +00:00
__filename__ = "epicyon.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
2022-02-03 13:58:20 +00:00
__version__ = "1.3.0"
2020-04-03 10:08:04 +00:00
__maintainer__ = "Bob Mottram"
2021-09-10 16:14:50 +00:00
__email__ = "bob@libreserver.org"
2020-04-03 10:08:04 +00:00
__status__ = "Production"
2021-06-15 15:08:12 +00:00
__module_group__ = "Commandline Interface"
2019-06-28 18:55:29 +00:00
2021-03-02 14:32:25 +00:00
import os
import shutil
import sys
import time
import argparse
2021-03-13 11:13:35 +00:00
import getpass
2022-02-24 10:18:54 +00:00
import datetime
2021-12-29 21:55:09 +00:00
from person import get_actor_json
from person import create_person
from person import create_group
from person import set_profile_image
2021-12-28 18:13:52 +00:00
from person import remove_account
from person import activate_account
from person import deactivate_account
2021-12-29 21:55:09 +00:00
from skills import set_skill_level
2021-12-28 22:22:09 +00:00
from roles import set_role
2021-12-29 21:55:09 +00:00
from webfinger import webfinger_handle
from bookmarks import send_bookmark_via_server
from bookmarks import send_undo_bookmark_via_server
2021-12-28 18:13:52 +00:00
from posts import get_instance_actor_key
2021-12-29 21:55:09 +00:00
from posts import send_mute_via_server
from posts import send_undo_mute_via_server
from posts import c2s_box_json
from posts import download_follow_collection
from posts import get_public_post_domains
from posts import get_public_post_domains_blocked
from posts import send_block_via_server
from posts import send_undo_block_via_server
2021-12-28 19:33:29 +00:00
from posts import create_public_post
2021-12-29 21:55:09 +00:00
from posts import delete_all_posts
from posts import archive_posts
from posts import send_post_via_server
from posts import get_public_posts_of_person
from posts import get_user_url
from posts import check_domains
2021-12-28 16:56:57 +00:00
from session import create_session
2021-12-29 21:55:09 +00:00
from session import get_json
2022-02-15 15:01:18 +00:00
from session import get_vcard
2021-12-29 21:55:09 +00:00
from session import download_html
from newswire import get_rss
from filters import add_filter
from filters import remove_filter
2019-06-28 18:55:29 +00:00
from pprint import pprint
2021-12-29 21:55:09 +00:00
from daemon import run_daemon
from follow import get_follow_requests_via_server
from follow import get_following_via_server
from follow import get_followers_via_server
from follow import clear_follows
from follow import add_follower_of_person
2021-12-28 20:32:11 +00:00
from follow import send_follow_requestViaServer
2021-12-29 21:55:09 +00:00
from follow import send_unfollow_request_via_server
from tests import test_shared_items_federation
from tests import test_group_follow
from tests import test_post_message_between_servers
from tests import test_follow_between_servers
from tests import test_client_to_server
from tests import test_update_actor
from tests import run_all_tests
2021-12-28 21:36:27 +00:00
from auth import store_basic_credentials
from auth import create_password
2021-12-26 18:17:37 +00:00
from utils import remove_domain_port
2021-12-26 18:14:21 +00:00
from utils import get_port_from_domain
2021-12-26 12:19:00 +00:00
from utils import has_users_path
2021-12-26 12:45:03 +00:00
from utils import get_full_domain
2021-12-27 20:38:02 +00:00
from utils import set_config_param
2021-12-26 14:08:58 +00:00
from utils import get_config_param
2021-12-27 19:05:25 +00:00
from utils import get_domain_from_actor
2021-12-27 22:19:18 +00:00
from utils import get_nickname_from_actor
2021-12-27 17:08:19 +00:00
from utils import follow_person
2021-12-28 14:41:10 +00:00
from utils import valid_nickname
2021-12-27 17:20:01 +00:00
from utils import get_protocol_prefixes
2021-12-26 12:02:29 +00:00
from utils import acct_dir
2021-12-29 21:55:09 +00:00
from media import archive_media
from media import get_attachment_media_type
from delete import send_delete_via_server
from like import send_like_via_server
from like import send_undo_like_via_server
from reaction import send_reaction_via_server
from reaction import send_undo_reaction_via_server
from reaction import valid_emoji_content
from skills import send_skill_via_server
from availability import set_availability
from availability import send_availability_via_server
from manualapprove import manual_deny_follow_request
from manualapprove import manual_approve_follow_request
from shares import send_share_via_server
from shares import send_undo_share_via_server
from shares import send_wanted_via_server
from shares import send_undo_wanted_via_server
from shares import add_share
from theme import set_theme
from announce import send_announce_via_server
from socnet import instances_graph
from migrate import migrate_accounts
from desktop_client import run_desktop_client
2022-02-24 10:18:54 +00:00
from happening import dav_month_via_server
2022-02-24 17:23:41 +00:00
from happening import dav_day_via_server
2019-06-30 21:20:02 +00:00
2020-04-03 10:08:04 +00:00
2022-01-02 12:53:25 +00:00
def str2bool(value_str) -> bool:
2020-09-25 09:10:21 +00:00
"""Returns true if the given value is a boolean
"""
2022-01-02 12:53:25 +00:00
if isinstance(value_str, bool):
return value_str
if value_str.lower() in ('yes', 'true', 't', 'y', '1'):
2019-07-03 09:24:55 +00:00
return True
2022-01-02 12:53:25 +00:00
if value_str.lower() in ('no', 'false', 'f', 'n', '0'):
2019-07-03 09:24:55 +00:00
return False
2022-01-02 12:53:25 +00:00
raise argparse.ArgumentTypeError('Boolean value expected.')
2019-07-05 09:20:54 +00:00
2020-04-03 10:08:04 +00:00
2022-02-24 10:18:54 +00:00
search_date = datetime.datetime.now()
2020-04-03 10:08:04 +00:00
parser = argparse.ArgumentParser(description='ActivityPub Server')
parser.add_argument('--eventDate', type=str,
default=None,
help='Date for an event when sending a c2s post' +
' YYYY-MM-DD')
parser.add_argument('--eventTime', type=str,
default=None,
help='Time for an event when sending a c2s post' +
' HH:MM')
parser.add_argument('--eventLocation', type=str,
default=None,
help='Location for an event when sending a c2s post')
2021-12-25 17:13:38 +00:00
parser.add_argument('--content_license_url', type=str,
2021-11-08 16:17:07 +00:00
default='https://creativecommons.org/licenses/by/4.0',
help='Url of the license used for the instance content')
2021-12-25 18:12:13 +00:00
parser.add_argument('--lists_enabled', type=str,
2021-10-21 14:06:25 +00:00
default=None,
help='Names of content warning lists enabled. ' +
'See the cwlists directory')
2021-06-20 17:48:50 +00:00
parser.add_argument('--userAgentBlocks', type=str,
default=None,
help='List of blocked user agents, separated by commas')
2022-03-06 12:31:58 +00:00
parser.add_argument('--crawlersAllowed', type=str,
default=None,
help='List of permitted web crawler user agents, ' +
'separated by commas')
parser.add_argument('--libretranslate', dest='libretranslateUrl', type=str,
default=None,
help='URL for LibreTranslate service')
2021-08-08 16:52:32 +00:00
parser.add_argument('--conversationId', dest='conversationId', type=str,
default=None,
help='Conversation Id which can be added ' +
'when sending a post')
parser.add_argument('--libretranslateApiKey',
dest='libretranslateApiKey', type=str,
default=None,
help='API key for LibreTranslate service')
2021-08-07 18:07:08 +00:00
parser.add_argument('--defaultCurrency', dest='defaultCurrency', type=str,
default=None,
2021-08-07 18:07:08 +00:00
help='Default currency EUR/GBP/USD...')
2020-04-03 10:08:04 +00:00
parser.add_argument('-n', '--nickname', dest='nickname', type=str,
default=None,
2019-07-09 15:51:31 +00:00
help='Nickname of the account to use')
2021-03-02 14:32:25 +00:00
parser.add_argument('--screenreader', dest='screenreader', type=str,
2021-03-09 21:25:12 +00:00
default=None,
help='Name of the screen reader: espeak/picospeaker')
2020-04-03 10:08:04 +00:00
parser.add_argument('--fol', '--follow', dest='follow', type=str,
default=None,
2019-07-09 15:51:31 +00:00
help='Handle of account to follow. eg. nickname@domain')
2020-04-03 10:08:04 +00:00
parser.add_argument('--unfol', '--unfollow', dest='unfollow', type=str,
default=None,
help='Handle of account stop following. ' +
'eg. nickname@domain')
parser.add_argument('-d', '--domain', dest='domain', type=str,
default=None,
2019-07-03 09:24:55 +00:00
help='Domain name of the server')
parser.add_argument('--notificationType', '--notifyType',
dest='notificationType', type=str,
default='notify-send',
help='Type of desktop notification command: ' +
2021-03-11 10:02:12 +00:00
'notify-send/zenity/osascript/New-BurntToastNotification')
2020-04-03 10:08:04 +00:00
parser.add_argument('-o', '--onion', dest='onion', type=str,
default=None,
help='Onion domain name of the server if ' +
'primarily on clearnet')
2021-12-25 20:50:24 +00:00
parser.add_argument('--i2p_domain', dest='i2p_domain', type=str,
default=None,
help='i2p domain name of the server if ' +
'primarily on clearnet')
2020-04-03 10:08:04 +00:00
parser.add_argument('-p', '--port', dest='port', type=int,
default=None,
2019-07-03 09:24:55 +00:00
help='Port number to run on')
2022-02-24 10:18:54 +00:00
parser.add_argument('--year', dest='year', type=int,
default=search_date.year,
help='Year for calendar query')
parser.add_argument('--month', dest='month', type=int,
default=search_date.month,
help='Month for calendar query')
2022-02-24 17:23:41 +00:00
parser.add_argument('--day', dest='day', type=int,
default=None,
help='Day for calendar query')
parser.add_argument('--postsPerSource',
2021-12-25 18:49:19 +00:00
dest='max_newswire_postsPerSource', type=int,
default=4,
help='Maximum newswire posts per feed or account')
2021-12-25 18:47:04 +00:00
parser.add_argument('--dormant_months',
dest='dormant_months', type=int,
default=3,
help='How many months does a followed account need to ' +
'be unseen for before being considered dormant')
2021-12-25 17:31:22 +00:00
parser.add_argument('--default_reply_interval_hrs',
dest='default_reply_interval_hrs', type=int,
2021-09-08 19:46:21 +00:00
default=1000,
help='How many hours after publication of a post ' +
'are replies to it permitted')
2021-12-25 18:44:18 +00:00
parser.add_argument('--send_threads_timeout_mins',
dest='send_threads_timeout_mins', type=int,
default=30,
help='How many minutes before a thread to send out ' +
'posts expires')
2021-12-25 18:49:19 +00:00
parser.add_argument('--max_newswire_posts',
dest='max_newswire_posts', type=int,
default=20,
help='Maximum newswire posts in the right column')
parser.add_argument('--maxFeedSize',
2021-12-25 20:09:29 +00:00
dest='max_newswire_feed_size_kb', type=int,
default=10240,
help='Maximum newswire rss/atom feed size in K')
2021-12-25 18:57:13 +00:00
parser.add_argument('--max_feed_item_size_kb',
dest='max_feed_item_size_kb', type=int,
default=2048,
help='Maximum size of an individual rss/atom ' +
'feed item in K')
2021-12-25 19:42:14 +00:00
parser.add_argument('--max_mirrored_articles',
dest='max_mirrored_articles', type=int,
2020-10-19 16:33:58 +00:00
default=100,
help='Maximum number of news articles to mirror.' +
' Set to zero for indefinite mirroring.')
2021-12-25 19:39:45 +00:00
parser.add_argument('--max_news_posts',
dest='max_news_posts', type=int,
2020-10-21 10:39:09 +00:00
default=0,
help='Maximum number of news timeline posts to keep. ' +
'Zero for no expiry.')
2021-12-25 19:37:10 +00:00
parser.add_argument('--max_followers',
dest='max_followers', type=int,
default=2000,
help='Maximum number of followers per account. ' +
'Zero for no limit.')
2021-01-10 21:38:28 +00:00
parser.add_argument('--followers',
dest='followers', type=str,
default='',
help='Show list of followers for the given actor')
2021-12-25 20:28:06 +00:00
parser.add_argument('--postcache', dest='max_recent_posts', type=int,
2020-08-26 10:25:08 +00:00
default=512,
help='The maximum number of recent posts to store in RAM')
2021-12-25 20:58:07 +00:00
parser.add_argument('--proxy', dest='proxy_port', type=int, default=None,
2019-08-14 13:52:19 +00:00
help='Proxy port number to run on')
2021-12-25 16:17:53 +00:00
parser.add_argument('--path', dest='base_dir',
2020-04-03 10:08:04 +00:00
type=str, default=os.getcwd(),
2019-07-03 09:24:55 +00:00
help='Directory in which to store posts')
2021-12-25 17:15:52 +00:00
parser.add_argument('--ytdomain', dest='yt_replace_domain',
type=str, default=None,
help='Domain used to replace youtube.com')
2021-12-25 20:55:47 +00:00
parser.add_argument('--twitterdomain', dest='twitter_replacement_domain',
2021-09-18 17:08:14 +00:00
type=str, default=None,
help='Domain used to replace twitter.com')
2020-04-03 10:08:04 +00:00
parser.add_argument('--language', dest='language',
type=str, default=None,
help='Specify a single language code, ' +
'eg. "en" or "fr" or "de"')
parser.add_argument('--languagesUnderstood', dest='languages_understood',
type=str, default=None,
help='List of the default languages understood eg. ' +
'"en / fr"')
2020-04-03 10:08:04 +00:00
parser.add_argument('-a', '--addaccount', dest='addaccount',
type=str, default=None,
2019-07-04 22:44:32 +00:00
help='Adds a new account')
2020-04-03 10:08:04 +00:00
parser.add_argument('-g', '--addgroup', dest='addgroup',
type=str, default=None,
2019-10-04 12:39:46 +00:00
help='Adds a new group')
2020-04-03 10:08:04 +00:00
parser.add_argument('--activate', dest='activate',
type=str, default=None,
2019-11-05 10:40:44 +00:00
help='Activate a previously deactivated account')
2020-04-03 10:08:04 +00:00
parser.add_argument('--deactivate', dest='deactivate',
type=str, default=None,
2019-11-05 10:37:37 +00:00
help='Deactivate an account')
2020-04-03 10:08:04 +00:00
parser.add_argument('-r', '--rmaccount', dest='rmaccount',
type=str, default=None,
2019-07-04 22:50:40 +00:00
help='Remove an account')
2020-04-03 10:08:04 +00:00
parser.add_argument('--rmgroup', dest='rmgroup',
type=str, default=None,
2019-10-04 12:59:31 +00:00
help='Remove a group')
2020-04-03 10:08:04 +00:00
parser.add_argument('--pass', '--password', dest='password',
type=str, default=None,
2019-07-04 22:44:32 +00:00
help='Set a password for an account')
2020-04-03 10:08:04 +00:00
parser.add_argument('--chpass', '--changepassword',
nargs='+', dest='changepassword',
2019-07-05 09:44:15 +00:00
help='Change the password for an account')
2020-04-03 10:08:04 +00:00
parser.add_argument('--actor', dest='actor', type=str,
default=None,
2019-07-05 15:53:26 +00:00
help='Show the json actor the given handle')
2020-04-03 10:08:04 +00:00
parser.add_argument('--posts', dest='posts', type=str,
default=None,
2019-07-03 10:31:02 +00:00
help='Show posts for the given handle')
2020-07-08 10:09:51 +00:00
parser.add_argument('--postDomains', dest='postDomains', type=str,
default=None,
help='Show domains referenced in public '
'posts for the given handle')
parser.add_argument('--postDomainsBlocked', dest='postDomainsBlocked',
type=str, default=None,
help='Show blocked domains referenced in public '
'posts for the given handle')
2021-12-29 21:55:09 +00:00
parser.add_argument('--check_domains', dest='check_domains', type=str,
2020-09-25 12:33:28 +00:00
default=None,
help='Check domains of non-mutual followers for '
'domains which are globally blocked by this instance')
2020-07-08 12:28:41 +00:00
parser.add_argument('--socnet', dest='socnet', type=str,
default=None,
help='Show dot diagram for social network '
'of federated instances')
2020-04-03 10:08:04 +00:00
parser.add_argument('--postsraw', dest='postsraw', type=str,
default=None,
2019-07-03 11:24:38 +00:00
help='Show raw json of posts for the given handle')
2022-02-15 15:01:18 +00:00
parser.add_argument('--vcard', dest='vcard', type=str, default=None,
help='Show the vcard for a given activitypub actor url')
2022-02-16 11:50:35 +00:00
parser.add_argument('--xmlvcard', dest='xmlvcard', type=str, default=None,
2022-02-16 11:10:44 +00:00
help='Show the xml vcard for a given ' +
'activitypub actor url')
2020-04-03 10:08:04 +00:00
parser.add_argument('--json', dest='json', type=str, default=None,
2019-07-12 10:53:49 +00:00
help='Show the json for a given activitypub url')
2021-12-23 20:59:36 +00:00
parser.add_argument('--htmlpost', dest='htmlpost', type=str, default=None,
help='Show the html for a given activitypub url')
2020-10-03 21:50:05 +00:00
parser.add_argument('--rss', dest='rss', type=str, default=None,
help='Show an rss feed for a given url')
2021-12-25 23:45:30 +00:00
parser.add_argument('-f', '--federate', nargs='+', dest='federation_list',
2019-07-03 09:24:55 +00:00
help='Specify federation list separated by spaces')
parser.add_argument('--federateshares', nargs='+',
2021-12-25 18:05:01 +00:00
dest='shared_items_federated_domains',
help='Specify federation list for shared items, ' +
'separated by spaces')
2021-03-24 13:52:20 +00:00
parser.add_argument("--following", "--followingList",
dest='followingList',
2021-03-24 12:43:24 +00:00
type=str2bool, nargs='?',
2021-03-24 13:15:43 +00:00
const=True, default=False,
2021-03-24 12:43:24 +00:00
help="Get the following list. Use nickname and " +
"domain options to specify the account")
2021-03-24 13:52:20 +00:00
parser.add_argument("--followersList",
dest='followersList',
type=str2bool, nargs='?',
const=True, default=False,
help="Get the followers list. Use nickname and " +
"domain options to specify the account")
parser.add_argument("--followRequestsList",
dest='followRequestsList',
type=str2bool, nargs='?',
const=True, default=False,
help="Get the follow requests list. Use nickname and " +
"domain options to specify the account")
2020-08-21 17:40:50 +00:00
parser.add_argument("--repliesEnabled", "--commentsEnabled",
dest='commentsEnabled',
type=str2bool, nargs='?',
const=True, default=True,
help="Enable replies to a post")
2022-02-24 10:18:54 +00:00
parser.add_argument("--dav",
dest='dav',
type=str2bool, nargs='?',
const=True, default=False,
help="Caldav")
2021-12-25 19:34:20 +00:00
parser.add_argument("--show_publish_as_icon",
dest='show_publish_as_icon',
type=str2bool, nargs='?',
const=True, default=True,
help="Whether to show newswire publish " +
"as an icon or a button")
2021-12-25 19:31:24 +00:00
parser.add_argument("--full_width_tl_button_header",
dest='full_width_tl_button_header',
type=str2bool, nargs='?',
const=True, default=False,
help="Whether to show the timeline " +
"button header containing inbox and outbox " +
"as the full width of the screen")
2021-12-25 19:19:14 +00:00
parser.add_argument("--icons_as_buttons",
dest='icons_as_buttons',
2020-10-25 20:38:01 +00:00
type=str2bool, nargs='?',
const=True, default=False,
help="Show header icons as buttons")
2021-12-25 18:29:29 +00:00
parser.add_argument("--log_login_failures",
dest='log_login_failures',
2021-06-09 15:19:30 +00:00
type=str2bool, nargs='?',
const=True, default=False,
help="Whether to log longin failures")
2021-12-25 19:09:03 +00:00
parser.add_argument("--rss_icon_at_top",
dest='rss_icon_at_top',
type=str2bool, nargs='?',
const=True, default=True,
help="Whether to show the rss icon at teh top or bottom" +
"of the timeline")
2021-12-25 18:20:56 +00:00
parser.add_argument("--low_bandwidth",
dest='low_bandwidth',
type=str2bool, nargs='?',
const=True, default=True,
help="Whether to use low bandwidth images")
2021-12-25 19:00:00 +00:00
parser.add_argument("--publish_button_at_top",
dest='publish_button_at_top',
2020-10-26 21:32:08 +00:00
type=str2bool, nargs='?',
const=True, default=False,
help="Whether to show the publish button at the top of " +
"the newswire column")
2021-12-25 18:54:50 +00:00
parser.add_argument("--allow_local_network_access",
dest='allow_local_network_access',
type=str2bool, nargs='?',
const=True, default=False,
help="Whether to allow access to local network " +
"addresses. This might be useful when deploying in " +
"a mesh network")
2021-12-25 18:40:32 +00:00
parser.add_argument("--verify_all_signatures",
dest='verify_all_signatures',
type=str2bool, nargs='?',
const=True, default=False,
help="Whether to require that all incoming " +
"posts have valid jsonld signatures")
2021-12-25 18:38:19 +00:00
parser.add_argument("--broch_mode",
dest='broch_mode',
2021-02-15 22:06:53 +00:00
type=str2bool, nargs='?',
const=True, default=False,
help="Enable broch mode")
2022-01-26 22:13:23 +00:00
parser.add_argument("--dyslexic_font",
dest='dyslexic_font',
type=str2bool, nargs='?',
const=True, default=False,
help="Use dyslexic font")
parser.add_argument("--nodeinfoaccounts",
2021-12-25 18:32:17 +00:00
dest='show_node_info_accounts',
type=str2bool, nargs='?',
const=True, default=False,
help="Show numbers of accounts within nodeinfo metadata")
parser.add_argument("--nodeinfoversion",
2021-12-25 18:35:24 +00:00
dest='show_node_info_version',
type=str2bool, nargs='?',
const=True, default=False,
help="Show version number within nodeinfo metadata")
parser.add_argument("--noKeyPress",
dest='noKeyPress',
type=str2bool, nargs='?',
const=True, default=False,
help="Notification daemon does not wait for keypresses")
parser.add_argument("--notifyShowNewPosts",
dest='notifyShowNewPosts',
type=str2bool, nargs='?',
const=True, default=False,
2021-03-17 10:04:49 +00:00
help="Desktop client shows/speaks new posts " +
"as they arrive")
2020-07-12 12:31:28 +00:00
parser.add_argument("--noapproval", type=str2bool, nargs='?',
const=True, default=False,
help="Allow followers without approval")
2020-04-03 10:08:04 +00:00
parser.add_argument("--mediainstance", type=str2bool, nargs='?',
const=True, default=False,
2019-11-28 16:16:43 +00:00
help="Media Instance - favor media over text")
parser.add_argument("--dateonly", type=str2bool, nargs='?',
const=True, default=False,
help="Only show the date at the bottom of posts")
2020-04-03 10:08:04 +00:00
parser.add_argument("--blogsinstance", type=str2bool, nargs='?',
const=True, default=False,
2020-02-24 14:39:25 +00:00
help="Blogs Instance - favor blogs over microblogging")
2020-10-07 09:10:42 +00:00
parser.add_argument("--newsinstance", type=str2bool, nargs='?',
const=True, default=False,
help="News Instance - favor news over microblogging")
parser.add_argument("--positivevoting", type=str2bool, nargs='?',
const=True, default=False,
help="On newswire, whether moderators vote " +
"positively for or veto against items")
2020-04-03 10:08:04 +00:00
parser.add_argument("--debug", type=str2bool, nargs='?',
const=True, default=False,
2019-07-06 20:19:49 +00:00
help="Show debug messages")
parser.add_argument("--notificationSounds", type=str2bool, nargs='?',
const=True, default=True,
help="Play notification sounds")
2021-12-25 21:07:06 +00:00
parser.add_argument("--secure_mode", type=str2bool, nargs='?',
2020-04-03 10:08:04 +00:00
const=True, default=False,
help="Requires all GET requests to be signed, " +
"so that the sender can be identifies and " +
"blocked if neccessary")
2021-12-25 21:34:53 +00:00
parser.add_argument("--instance_only_skills_search", type=str2bool, nargs='?',
2020-04-03 10:08:04 +00:00
const=True, default=False,
help="Skills searches only return " +
"results from this instance")
parser.add_argument("--http", type=str2bool, nargs='?',
const=True, default=False,
2019-07-06 20:19:49 +00:00
help="Use http only")
2020-06-09 11:51:51 +00:00
parser.add_argument("--gnunet", type=str2bool, nargs='?',
const=True, default=False,
help="Use gnunet protocol only")
2020-04-03 10:08:04 +00:00
parser.add_argument("--dat", type=str2bool, nargs='?',
const=True, default=False,
2019-07-06 20:19:49 +00:00
help="Use dat protocol only")
2020-05-17 09:37:59 +00:00
parser.add_argument("--hyper", type=str2bool, nargs='?',
const=True, default=False,
help="Use hypercore protocol only")
2020-04-03 10:08:04 +00:00
parser.add_argument("--i2p", type=str2bool, nargs='?',
const=True, default=False,
2020-02-17 17:18:21 +00:00
help="Use i2p protocol only")
2020-04-03 10:08:04 +00:00
parser.add_argument("--tor", type=str2bool, nargs='?',
const=True, default=False,
2019-07-06 20:19:49 +00:00
help="Route via Tor")
parser.add_argument("--migrations", type=str2bool, nargs='?',
const=True, default=False,
help="Migrate moved accounts")
2020-04-03 10:08:04 +00:00
parser.add_argument("--tests", type=str2bool, nargs='?',
const=True, default=False,
2019-07-06 20:19:49 +00:00
help="Run unit tests")
2020-04-03 10:08:04 +00:00
parser.add_argument("--testsnetwork", type=str2bool, nargs='?',
const=True, default=False,
2019-07-06 20:19:49 +00:00
help="Run network unit tests")
2020-04-03 10:08:04 +00:00
parser.add_argument("--testdata", type=str2bool, nargs='?',
const=True, default=False,
2019-07-06 20:19:49 +00:00
help="Generate some data for testing purposes")
2020-04-03 10:08:04 +00:00
parser.add_argument('--icon', '--avatar', dest='avatar', type=str,
default=None,
2019-07-12 14:31:56 +00:00
help='Set the avatar filename for an account')
2020-04-03 10:08:04 +00:00
parser.add_argument('--image', '--background', dest='backgroundImage',
type=str, default=None,
help='Set the profile background image for an account')
2020-04-03 10:08:04 +00:00
parser.add_argument('--archive', dest='archive', type=str,
default=None,
2019-07-12 20:43:55 +00:00
help='Archive old files to the given directory')
2020-12-08 14:09:54 +00:00
parser.add_argument('--archiveweeks', dest='archiveWeeks', type=int,
default=4,
2020-04-03 10:08:04 +00:00
help='Specify the number of weeks after which ' +
2020-12-08 14:09:54 +00:00
'media will be archived')
parser.add_argument('--maxposts', dest='archiveMaxPosts', type=int,
default=32000,
2019-07-12 20:43:55 +00:00
help='Maximum number of posts in in/outbox')
2020-10-08 19:53:30 +00:00
parser.add_argument('--minimumvotes', dest='minimumvotes', type=int,
default=1,
2020-10-08 17:49:03 +00:00
help='Minimum number of votes to remove or add' +
' a newswire item')
2021-12-25 18:23:12 +00:00
parser.add_argument('--max_like_count', dest='max_like_count', type=int,
default=10,
help='Maximum number of likes displayed on a post')
2020-10-09 12:15:20 +00:00
parser.add_argument('--votingtime', dest='votingtime', type=int,
default=1440,
help='Time to vote on newswire items in minutes')
2020-04-03 10:08:04 +00:00
parser.add_argument('--message', dest='message', type=str,
default=None,
2019-07-12 22:29:10 +00:00
help='Message content')
2020-04-03 10:08:04 +00:00
parser.add_argument('--delete', dest='delete', type=str,
default=None,
2019-07-17 17:29:33 +00:00
help='Delete a specified post')
2020-04-03 10:08:04 +00:00
parser.add_argument("--allowdeletion", type=str2bool, nargs='?',
const=True, default=False,
2019-07-17 17:44:26 +00:00
help="Do not allow deletions")
2020-04-03 10:08:04 +00:00
parser.add_argument('--repeat', '--announce', dest='announce', type=str,
default=None,
2019-07-16 20:08:30 +00:00
help='Announce/repeat a url')
2021-03-18 11:03:39 +00:00
parser.add_argument('--box', type=str,
default=None,
help='Returns the json for a given timeline, ' +
'with authentication')
parser.add_argument('--page', '--pageNumber', dest='pageNumber', type=int,
default=1,
help='Page number when using the --box option')
2020-04-03 10:08:04 +00:00
parser.add_argument('--favorite', '--like', dest='like', type=str,
default=None, help='Like a url')
parser.add_argument('--undolike', '--unlike', dest='undolike', type=str,
default=None, help='Undo a like of a url')
2021-11-10 12:16:03 +00:00
parser.add_argument('--react', '--reaction', dest='react', type=str,
default=None, help='Reaction url')
parser.add_argument('--emoji', type=str,
default=None, help='Reaction emoji')
parser.add_argument('--undoreact', '--undoreaction', dest='undoreact',
type=str,
default=None, help='Reaction url')
2021-03-20 10:43:52 +00:00
parser.add_argument('--bookmark', '--bm', dest='bookmark', type=str,
default=None,
help='Bookmark the url of a post')
parser.add_argument('--unbookmark', '--unbm', dest='unbookmark', type=str,
default=None,
help='Undo a bookmark given the url of a post')
2020-04-03 10:08:04 +00:00
parser.add_argument('--sendto', dest='sendto', type=str,
default=None, help='Address to send a post to')
parser.add_argument('--attach', dest='attach', type=str,
default=None, help='File to attach to a post')
parser.add_argument('--imagedescription', dest='imageDescription', type=str,
default=None, help='Description of an attached image')
2021-05-09 19:11:05 +00:00
parser.add_argument('--city', dest='city', type=str,
2021-05-09 19:29:53 +00:00
default='London, England',
2021-05-09 19:11:05 +00:00
help='Spoofed city for image metadata misdirection')
2020-04-03 10:08:04 +00:00
parser.add_argument('--warning', '--warn', '--cwsubject', '--subject',
dest='subject', type=str, default=None,
2019-07-12 22:29:10 +00:00
help='Subject of content warning')
2020-04-03 10:08:04 +00:00
parser.add_argument('--reply', '--replyto', dest='replyto', type=str,
default=None, help='Url of post to reply to')
parser.add_argument("--followersonly", type=str2bool, nargs='?',
const=True, default=True,
2019-07-13 09:22:25 +00:00
help="Send to followers only")
2020-04-03 10:08:04 +00:00
parser.add_argument("--followerspending", type=str2bool, nargs='?',
const=True, default=False,
help="Show a list of followers pending")
2020-04-03 10:08:04 +00:00
parser.add_argument('--approve', dest='approve', type=str, default=None,
help='Approve a follow request')
2020-04-03 10:08:04 +00:00
parser.add_argument('--deny', dest='deny', type=str, default=None,
help='Deny a follow request')
2020-04-03 10:08:04 +00:00
parser.add_argument("-c", "--client", type=str2bool, nargs='?',
const=True, default=False,
2019-07-13 09:22:25 +00:00
help="Use as an ActivityPub client")
2021-12-25 21:11:35 +00:00
parser.add_argument('--maxreplies', dest='max_replies', type=int, default=64,
2019-07-13 21:00:12 +00:00
help='Maximum number of replies to a post')
2021-12-25 21:02:44 +00:00
parser.add_argument('--max_mentions', '--hellthread', dest='max_mentions',
2020-04-03 10:08:04 +00:00
type=int, default=10,
2019-09-30 10:15:20 +00:00
help='Maximum number of mentions within a post')
2021-12-25 21:04:51 +00:00
parser.add_argument('--max_emoji', '--maxemoji', dest='max_emoji',
2020-04-03 10:08:04 +00:00
type=int, default=10,
2019-11-16 14:49:21 +00:00
help='Maximum number of emoji within a post')
2020-04-03 10:08:04 +00:00
parser.add_argument('--role', dest='role', type=str, default=None,
help='Set a role for a person')
2020-04-03 10:08:04 +00:00
parser.add_argument('--skill', dest='skill', type=str, default=None,
help='Set a skill for a person')
2020-04-03 10:08:04 +00:00
parser.add_argument('--level', dest='skillLevelPercent', type=int,
default=None,
help='Set a skill level for a person as a ' +
'percentage, or zero to remove')
parser.add_argument('--status', '--availability', dest='availability',
type=str, default=None,
2019-07-14 13:30:59 +00:00
help='Set an availability status')
2021-03-16 22:14:03 +00:00
parser.add_argument('--desktop', dest='desktop',
2021-03-01 19:16:33 +00:00
type=str, default=None,
2021-03-16 22:11:54 +00:00
help='Run desktop client')
2020-04-03 10:08:04 +00:00
parser.add_argument('--block', dest='block', type=str, default=None,
2019-07-14 19:57:05 +00:00
help='Block a particular address')
2020-04-03 10:08:04 +00:00
parser.add_argument('--unblock', dest='unblock', type=str, default=None,
2019-07-14 19:57:05 +00:00
help='Remove a block on a particular address')
2021-03-20 21:20:41 +00:00
parser.add_argument('--mute', dest='mute', type=str, default=None,
help='Mute a particular post URL')
parser.add_argument('--unmute', dest='unmute', type=str, default=None,
help='Unmute a particular post URL')
2020-04-03 10:08:04 +00:00
parser.add_argument('--filter', dest='filterStr', type=str, default=None,
help='Adds a word or phrase which if present will ' +
'cause a message to be ignored')
parser.add_argument('--unfilter', dest='unfilterStr', type=str, default=None,
2019-07-14 20:50:27 +00:00
help='Remove a filter on a particular word or phrase')
2021-12-25 21:13:55 +00:00
parser.add_argument('--domainmax', dest='domain_max_posts_per_day', type=int,
2020-04-03 10:08:04 +00:00
default=8640,
help='Maximum number of received posts ' +
'from a domain per day')
2021-12-25 21:18:07 +00:00
parser.add_argument('--accountmax', dest='account_max_posts_per_day', type=int,
2020-04-03 10:08:04 +00:00
default=8640,
help='Maximum number of received posts ' +
'from an account per day')
parser.add_argument('--itemName', dest='itemName', type=str,
default=None,
2019-07-23 21:39:07 +00:00
help='Name of an item being shared')
2020-04-03 10:08:04 +00:00
parser.add_argument('--undoItemName', dest='undoItemName', type=str,
default=None,
2019-07-23 21:45:53 +00:00
help='Name of an shared item to remove')
2021-08-09 19:46:21 +00:00
parser.add_argument('--wantedItemName', dest='wantedItemName', type=str,
default=None,
help='Name of a wanted item')
parser.add_argument('--undoWantedItemName', dest='undoWantedItemName',
type=str, default=None,
help='Name of a wanted item to remove')
2020-04-03 10:08:04 +00:00
parser.add_argument('--summary', dest='summary', type=str,
default=None,
2019-07-23 21:39:07 +00:00
help='Description of an item being shared')
2020-04-03 10:08:04 +00:00
parser.add_argument('--itemImage', dest='itemImage', type=str,
default=None,
2019-07-23 21:39:07 +00:00
help='Filename of an image for an item being shared')
2021-07-28 09:44:19 +00:00
parser.add_argument('--itemQty', dest='itemQty', type=float,
2021-07-24 11:30:46 +00:00
default=1,
help='Quantity of items being shared')
2021-07-24 22:08:11 +00:00
parser.add_argument('--itemPrice', dest='itemPrice', type=str,
2021-07-25 13:09:39 +00:00
default="0.00",
2021-07-24 22:08:11 +00:00
help='Total price of items being shared')
parser.add_argument('--itemCurrency', dest='itemCurrency', type=str,
default="EUR",
help='Currency of items being shared')
2020-04-03 10:08:04 +00:00
parser.add_argument('--itemType', dest='itemType', type=str,
default=None,
2019-07-23 21:39:07 +00:00
help='Type of item being shared')
2020-04-03 10:08:04 +00:00
parser.add_argument('--itemCategory', dest='itemCategory', type=str,
default=None,
2019-07-23 21:39:07 +00:00
help='Category of item being shared')
2020-04-03 10:08:04 +00:00
parser.add_argument('--location', dest='location', type=str, default=None,
2019-07-23 21:39:07 +00:00
help='Location/City of item being shared')
2020-04-03 10:08:04 +00:00
parser.add_argument('--duration', dest='duration', type=str, default=None,
2019-07-23 21:39:07 +00:00
help='Duration for which to share an item')
2020-04-03 10:08:04 +00:00
parser.add_argument('--registration', dest='registration', type=str,
2021-06-04 14:45:47 +00:00
default='open',
2019-08-08 10:50:58 +00:00
help='Whether new registrations are open or closed')
2020-04-03 10:08:04 +00:00
parser.add_argument("--nosharedinbox", type=str2bool, nargs='?',
const=True, default=False,
2019-11-15 22:07:06 +00:00
help='Disable shared inbox')
2020-04-03 10:08:04 +00:00
parser.add_argument('--maxregistrations', dest='maxRegistrations',
2021-06-04 14:45:47 +00:00
type=int, default=10,
2019-08-08 10:50:58 +00:00
help='The maximum number of new registrations')
2020-04-03 10:08:04 +00:00
parser.add_argument("--resetregistrations", type=str2bool, nargs='?',
const=True, default=False,
2019-08-08 10:50:58 +00:00
help="Reset the number of remaining registrations")
2019-07-03 10:31:02 +00:00
2020-04-03 10:08:04 +00:00
args = parser.parse_args()
debug = False
2019-07-03 16:14:45 +00:00
if args.debug:
2020-04-03 10:08:04 +00:00
debug = True
2021-03-14 19:24:57 +00:00
else:
if os.path.isfile('debug'):
debug = True
2019-07-03 16:14:45 +00:00
2019-07-03 09:24:55 +00:00
if args.tests:
2021-12-29 21:55:09 +00:00
run_all_tests()
2019-07-03 09:24:55 +00:00
sys.exit()
2019-07-03 10:31:02 +00:00
if args.testsnetwork:
print('Network Tests')
2021-12-25 16:17:53 +00:00
base_dir = os.getcwd()
2021-12-29 21:55:09 +00:00
test_shared_items_federation(base_dir)
test_group_follow(base_dir)
test_post_message_between_servers(base_dir)
test_follow_between_servers(base_dir)
test_client_to_server(base_dir)
test_update_actor(base_dir)
2019-07-27 22:59:01 +00:00
print('All tests succeeded')
2019-07-03 10:31:02 +00:00
sys.exit()
2019-07-05 15:53:26 +00:00
2021-12-25 17:09:22 +00:00
http_prefix = 'https'
2020-06-19 11:12:26 +00:00
if args.http or args.i2p:
2021-12-25 17:09:22 +00:00
http_prefix = 'http'
2020-06-09 12:07:43 +00:00
elif args.gnunet:
2021-12-25 17:09:22 +00:00
http_prefix = 'gnunet'
2019-07-19 13:32:58 +00:00
2021-12-25 16:17:53 +00:00
base_dir = args.base_dir
if base_dir.endswith('/'):
2019-08-20 10:10:33 +00:00
print("--path option should not end with '/'")
sys.exit()
# automatic translations
if args.libretranslateUrl:
if '://' in args.libretranslateUrl and \
'.' in args.libretranslateUrl:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'libretranslateUrl', args.libretranslateUrl)
if args.libretranslateApiKey:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'libretranslateApiKey',
args.libretranslateApiKey)
2019-07-03 10:33:55 +00:00
if args.posts:
2021-09-15 11:14:31 +00:00
if not args.domain:
2021-12-26 14:08:58 +00:00
originDomain = get_config_param(base_dir, 'domain')
2021-09-15 11:13:31 +00:00
else:
2021-09-15 11:14:31 +00:00
originDomain = args.domain
2021-09-15 11:36:46 +00:00
if debug:
print('originDomain: ' + str(originDomain))
2019-07-05 15:53:26 +00:00
if '@' not in args.posts:
2020-07-08 09:21:36 +00:00
if '/users/' in args.posts:
2022-01-04 21:19:06 +00:00
posts_nickname = get_nickname_from_actor(args.posts)
posts_domain, posts_port = get_domain_from_actor(args.posts)
2020-12-16 10:30:54 +00:00
args.posts = \
2022-01-04 21:19:06 +00:00
get_full_domain(posts_nickname + '@' + posts_domain,
posts_port)
2020-07-08 09:21:36 +00:00
else:
print('Syntax: --posts nickname@domain')
sys.exit()
2019-07-19 16:59:14 +00:00
if not args.http:
2020-04-03 10:08:04 +00:00
args.port = 443
nickname = args.posts.split('@')[0]
domain = args.posts.split('@')[1]
2021-12-25 21:09:22 +00:00
proxy_type = None
2020-06-09 11:03:59 +00:00
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2020-07-08 09:21:36 +00:00
if domain.endswith('.onion'):
args.port = 80
2020-06-09 11:03:59 +00:00
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2020-07-08 09:21:36 +00:00
if domain.endswith('.i2p'):
args.port = 80
2020-06-09 11:51:51 +00:00
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
if not args.language:
args.language = 'en'
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, originDomain)
2021-12-29 21:55:09 +00:00
get_public_posts_of_person(base_dir, nickname, domain, False, True,
proxy_type, args.port, http_prefix, debug,
__version__, args.language,
signing_priv_key_pem, originDomain)
2019-07-03 11:24:38 +00:00
sys.exit()
2020-07-08 10:09:51 +00:00
if args.postDomains:
if '@' not in args.postDomains:
if '/users/' in args.postDomains:
2022-01-04 21:19:06 +00:00
posts_nickname = get_nickname_from_actor(args.postDomains)
posts_domain, posts_port = get_domain_from_actor(args.postDomains)
2020-12-16 10:30:54 +00:00
args.postDomains = \
2022-01-04 21:19:06 +00:00
get_full_domain(posts_nickname + '@' + posts_domain,
posts_port)
2020-07-08 10:09:51 +00:00
else:
2020-07-08 10:17:30 +00:00
print('Syntax: --postDomains nickname@domain')
2020-07-08 10:09:51 +00:00
sys.exit()
if not args.http:
args.port = 443
nickname = args.postDomains.split('@')[0]
domain = args.postDomains.split('@')[1]
2021-12-25 21:09:22 +00:00
proxy_type = None
2020-07-08 10:09:51 +00:00
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2020-07-08 10:09:51 +00:00
if domain.endswith('.onion'):
args.port = 80
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2020-07-08 10:09:51 +00:00
if domain.endswith('.i2p'):
args.port = 80
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
2022-01-04 21:19:06 +00:00
word_frequency = {}
domain_list = []
if not args.language:
args.language = 'en'
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-09-15 14:05:08 +00:00
if not args.domain:
2021-12-26 14:08:58 +00:00
originDomain = get_config_param(base_dir, 'domain')
2021-09-15 14:05:08 +00:00
else:
originDomain = args.domain
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, originDomain)
2022-01-04 21:19:06 +00:00
domain_list = \
2021-12-29 21:55:09 +00:00
get_public_post_domains(None,
base_dir, nickname, domain,
originDomain,
proxy_type, args.port,
http_prefix, debug,
__version__,
2022-01-04 21:19:06 +00:00
word_frequency, domain_list,
2021-12-29 21:55:09 +00:00
args.language,
signing_priv_key_pem)
2022-01-04 21:19:06 +00:00
for postDomain in domain_list:
2020-07-08 10:09:51 +00:00
print(postDomain)
sys.exit()
if args.postDomainsBlocked:
# Domains which were referenced in public posts by a
# given handle but which are globally blocked on this instance
if '@' not in args.postDomainsBlocked:
if '/users/' in args.postDomainsBlocked:
2022-01-04 21:19:06 +00:00
posts_nickname = get_nickname_from_actor(args.postDomainsBlocked)
posts_domain, posts_port = \
2021-12-27 19:05:25 +00:00
get_domain_from_actor(args.postDomainsBlocked)
2020-12-16 10:30:54 +00:00
args.postDomainsBlocked = \
2022-01-04 21:19:06 +00:00
get_full_domain(posts_nickname + '@' + posts_domain,
posts_port)
else:
print('Syntax: --postDomainsBlocked nickname@domain')
sys.exit()
if not args.http:
args.port = 443
nickname = args.postDomainsBlocked.split('@')[0]
domain = args.postDomainsBlocked.split('@')[1]
2021-12-25 21:09:22 +00:00
proxy_type = None
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
if domain.endswith('.onion'):
args.port = 80
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
if domain.endswith('.i2p'):
args.port = 80
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
2022-01-04 21:19:06 +00:00
word_frequency = {}
domain_list = []
if not args.language:
args.language = 'en'
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2022-01-04 21:19:06 +00:00
domain_list = \
2021-12-29 21:55:09 +00:00
get_public_post_domains_blocked(None,
base_dir, nickname, domain,
proxy_type, args.port,
http_prefix, debug,
__version__,
2022-01-04 21:19:06 +00:00
word_frequency, domain_list,
2021-12-29 21:55:09 +00:00
args.language,
signing_priv_key_pem)
2022-01-04 21:19:06 +00:00
for postDomain in domain_list:
print(postDomain)
sys.exit()
2021-12-29 21:55:09 +00:00
if args.check_domains:
2020-09-25 12:33:28 +00:00
# Domains which were referenced in public posts by a
# given handle but which are globally blocked on this instance
2021-12-29 21:55:09 +00:00
if '@' not in args.check_domains:
if '/users/' in args.check_domains:
2022-01-04 21:19:06 +00:00
posts_nickname = get_nickname_from_actor(args.posts)
posts_domain, posts_port = get_domain_from_actor(args.posts)
2021-12-29 21:55:09 +00:00
args.check_domains = \
2022-01-04 21:19:06 +00:00
get_full_domain(posts_nickname + '@' + posts_domain,
posts_port)
2020-09-25 12:33:28 +00:00
else:
2021-12-29 21:55:09 +00:00
print('Syntax: --check_domains nickname@domain')
2020-09-25 12:33:28 +00:00
sys.exit()
if not args.http:
args.port = 443
2021-12-29 21:55:09 +00:00
nickname = args.check_domains.split('@')[0]
domain = args.check_domains.split('@')[1]
2021-12-25 21:09:22 +00:00
proxy_type = None
2020-09-25 12:33:28 +00:00
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2020-09-25 12:33:28 +00:00
if domain.endswith('.onion'):
args.port = 80
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2020-09-25 12:33:28 +00:00
if domain.endswith('.i2p'):
args.port = 80
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
2022-01-04 21:19:06 +00:00
max_blocked_domains = 0
if not args.language:
args.language = 'en'
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-12-29 21:55:09 +00:00
check_domains(None,
base_dir, nickname, domain,
proxy_type, args.port,
http_prefix, debug,
__version__,
2022-01-04 21:19:06 +00:00
max_blocked_domains, False, args.language,
2021-12-29 21:55:09 +00:00
signing_priv_key_pem)
2020-09-25 12:33:28 +00:00
sys.exit()
2020-07-08 12:28:41 +00:00
if args.socnet:
if ',' not in args.socnet:
print('Syntax: '
'--socnet nick1@domain1,nick2@domain2,nick3@domain3')
sys.exit()
if not args.http:
args.port = 443
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
if not args.language:
args.language = 'en'
if not args.domain:
2021-12-26 14:08:58 +00:00
args.domain = get_config_param(base_dir, 'domain')
2021-09-10 19:18:27 +00:00
domain = ''
if args.domain:
domain = args.domain
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2022-01-04 21:19:06 +00:00
dot_graph = instances_graph(base_dir, args.socnet,
proxy_type, args.port,
http_prefix, debug,
__version__, args.language,
signing_priv_key_pem)
try:
2022-01-04 21:19:06 +00:00
with open('socnet.dot', 'w+') as fp_soc:
fp_soc.write(dot_graph)
print('Saved to socnet.dot')
2021-11-25 22:22:54 +00:00
except OSError:
2021-10-29 18:48:15 +00:00
print('EX: commandline unable to write socnet.dot')
2020-07-08 12:28:41 +00:00
sys.exit()
2019-07-03 11:24:38 +00:00
if args.postsraw:
2021-09-15 11:14:31 +00:00
if not args.domain:
2021-12-26 14:08:58 +00:00
originDomain = get_config_param(base_dir, 'domain')
2021-09-15 11:13:31 +00:00
else:
2021-09-15 11:14:31 +00:00
originDomain = args.domain
2021-09-15 11:36:46 +00:00
if debug:
print('originDomain: ' + str(originDomain))
2019-07-06 21:58:56 +00:00
if '@' not in args.postsraw:
2019-07-05 15:53:26 +00:00
print('Syntax: --postsraw nickname@domain')
2020-03-22 21:16:02 +00:00
sys.exit()
2019-07-19 16:59:14 +00:00
if not args.http:
2020-04-03 10:08:04 +00:00
args.port = 443
nickname = args.postsraw.split('@')[0]
domain = args.postsraw.split('@')[1]
2021-12-25 21:09:22 +00:00
proxy_type = None
2020-06-09 11:03:59 +00:00
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2020-06-09 11:03:59 +00:00
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2020-06-09 11:51:51 +00:00
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
if not args.language:
args.language = 'en'
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, originDomain)
2021-12-29 21:55:09 +00:00
get_public_posts_of_person(base_dir, nickname, domain, False, False,
proxy_type, args.port, http_prefix, debug,
__version__, args.language,
signing_priv_key_pem, originDomain)
2019-07-03 10:33:55 +00:00
sys.exit()
2019-11-13 10:50:16 +00:00
if args.json:
2021-12-28 16:56:57 +00:00
session = create_session(None)
2022-01-04 21:19:06 +00:00
profile_str = 'https://www.w3.org/ns/activitystreams'
as_header = {
'Accept': 'application/ld+json; profile="' + profile_str + '"'
2020-03-22 20:36:19 +00:00
}
if not args.domain:
2021-12-26 14:08:58 +00:00
args.domain = get_config_param(base_dir, 'domain')
2021-09-10 19:17:22 +00:00
domain = ''
if args.domain:
domain = args.domain
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-09-01 17:48:44 +00:00
if debug:
2021-12-25 16:17:53 +00:00
print('base_dir: ' + str(base_dir))
2021-12-25 23:03:28 +00:00
if signing_priv_key_pem:
2021-09-01 17:48:44 +00:00
print('Obtained instance actor signing key')
else:
2021-09-10 19:17:22 +00:00
print('Did not obtain instance actor key for ' + domain)
2022-01-04 21:19:06 +00:00
test_json = get_json(signing_priv_key_pem, session, args.json, as_header,
None, debug, __version__, http_prefix, domain)
if test_json:
pprint(test_json)
2021-12-23 20:59:36 +00:00
sys.exit()
2022-02-15 15:01:18 +00:00
if args.vcard:
session = create_session(None)
if not args.domain:
args.domain = get_config_param(base_dir, 'domain')
domain = ''
if args.domain:
domain = args.domain
2022-02-16 11:10:44 +00:00
test_vcard = get_vcard(False, session, args.vcard,
None, debug, __version__, http_prefix, domain)
if test_vcard:
print(test_vcard)
sys.exit()
2022-02-16 11:50:35 +00:00
if args.xmlvcard:
2022-02-16 11:10:44 +00:00
session = create_session(None)
if not args.domain:
args.domain = get_config_param(base_dir, 'domain')
domain = ''
if args.domain:
domain = args.domain
2022-02-16 12:05:42 +00:00
test_vcard = get_vcard(True, session, args.xmlvcard,
2022-02-15 15:01:18 +00:00
None, debug, __version__, http_prefix, domain)
if test_vcard:
print(test_vcard)
sys.exit()
2021-12-23 20:59:36 +00:00
if args.htmlpost:
2021-12-28 16:56:57 +00:00
session = create_session(None)
2022-01-04 21:19:06 +00:00
profile_str = 'https://www.w3.org/ns/activitystreams'
as_header = {
'Accept': 'text/html; profile="' + profile_str + '"'
2021-12-23 20:59:36 +00:00
}
if not args.domain:
2021-12-26 14:08:58 +00:00
args.domain = get_config_param(base_dir, 'domain')
2021-12-23 20:59:36 +00:00
domain = ''
if args.domain:
domain = args.domain
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-12-23 20:59:36 +00:00
if debug:
2021-12-25 16:17:53 +00:00
print('base_dir: ' + str(base_dir))
2021-12-25 23:03:28 +00:00
if signing_priv_key_pem:
2021-12-23 20:59:36 +00:00
print('Obtained instance actor signing key')
else:
print('Did not obtain instance actor key for ' + domain)
2021-12-29 21:55:09 +00:00
testHtml = download_html(signing_priv_key_pem, session, args.htmlpost,
2022-01-04 21:19:06 +00:00
as_header, None, debug, __version__,
2021-12-29 21:55:09 +00:00
http_prefix, domain)
2021-12-23 20:59:36 +00:00
if testHtml:
print(testHtml)
2019-11-13 10:50:16 +00:00
sys.exit()
2019-08-20 10:10:33 +00:00
# create cache for actors
2021-12-25 16:17:53 +00:00
if not os.path.isdir(base_dir + '/cache'):
os.mkdir(base_dir + '/cache')
if not os.path.isdir(base_dir + '/cache/actors'):
2019-08-20 10:10:33 +00:00
print('Creating actors cache')
2021-12-25 16:17:53 +00:00
os.mkdir(base_dir + '/cache/actors')
if not os.path.isdir(base_dir + '/cache/announce'):
2019-08-20 12:39:59 +00:00
print('Creating announce cache')
2021-12-25 16:17:53 +00:00
os.mkdir(base_dir + '/cache/announce')
2019-07-05 09:20:54 +00:00
# set the theme in config.json
2021-12-26 14:08:58 +00:00
theme_name = get_config_param(base_dir, 'theme')
2021-12-25 23:35:50 +00:00
if not theme_name:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'theme', 'default')
2021-12-25 23:35:50 +00:00
theme_name = 'default'
2019-11-13 12:45:41 +00:00
2019-11-28 16:16:43 +00:00
if not args.mediainstance:
2021-12-30 13:56:38 +00:00
media_instance = get_config_param(base_dir, 'mediaInstance')
2021-12-25 20:25:07 +00:00
if media_instance is not None:
args.mediainstance = media_instance
if args.mediainstance:
args.blogsinstance = False
2020-10-07 09:10:42 +00:00
args.newsinstance = False
if not args.newsinstance:
2021-12-30 13:56:38 +00:00
news_instance = get_config_param(base_dir, 'newsInstance')
2021-12-25 20:20:08 +00:00
if news_instance is not None:
args.newsinstance = news_instance
2020-10-07 09:10:42 +00:00
if args.newsinstance:
args.blogsinstance = False
args.mediainstance = False
2020-02-24 14:39:25 +00:00
if not args.blogsinstance:
2021-12-30 13:56:38 +00:00
blogs_instance = get_config_param(base_dir, 'blogsInstance')
2021-12-25 20:22:25 +00:00
if blogs_instance is not None:
args.blogsinstance = blogs_instance
if args.blogsinstance:
args.mediainstance = False
2020-10-07 09:10:42 +00:00
args.newsinstance = False
2020-03-22 21:16:02 +00:00
2019-11-13 12:45:41 +00:00
# set the instance title in config.json
2021-12-26 14:08:58 +00:00
title = get_config_param(base_dir, 'instanceTitle')
2019-11-13 12:45:41 +00:00
if not title:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'instanceTitle', 'Epicyon')
2019-11-13 12:45:41 +00:00
# set the instance description in config.json
2021-12-26 14:08:58 +00:00
descFull = get_config_param(base_dir, 'instanceDescription')
2019-11-13 12:45:41 +00:00
if not descFull:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'instanceDescription',
'Just another ActivityPub server')
2019-11-13 12:45:41 +00:00
# set the short instance description in config.json
2021-12-26 14:08:58 +00:00
descShort = get_config_param(base_dir, 'instanceDescriptionShort')
2019-11-13 12:45:41 +00:00
if not descShort:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'instanceDescriptionShort',
'Just another ActivityPub server')
2019-11-13 12:45:41 +00:00
2019-07-19 18:12:50 +00:00
if args.domain:
2020-04-03 10:08:04 +00:00
domain = args.domain
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'domain', domain)
2019-11-11 17:49:08 +00:00
2020-12-02 17:07:47 +00:00
if args.rss:
2021-12-28 16:56:57 +00:00
session = create_session(None)
2021-12-29 21:55:09 +00:00
testRSS = get_rss(base_dir, domain, session, args.rss,
False, False, 1000, 1000, 1000, 1000, debug)
2020-12-02 17:07:47 +00:00
pprint(testRSS)
sys.exit()
if args.onion:
if not args.onion.endswith('.onion'):
2020-04-03 10:08:04 +00:00
print(args.onion + ' does not look like an onion domain')
sys.exit()
if '://' in args.onion:
2020-04-03 10:08:04 +00:00
args.onion = args.onion.split('://')[1]
2021-12-25 20:43:43 +00:00
onion_domain = args.onion
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'onion', onion_domain)
2021-12-25 20:50:24 +00:00
i2p_domain = None
if args.i2p_domain:
if not args.i2p_domain.endswith('.i2p'):
print(args.i2p_domain + ' does not look like an i2p domain')
sys.exit()
2021-12-25 20:50:24 +00:00
if '://' in args.i2p_domain:
args.onion = args.onion.split('://')[1]
2021-12-25 20:50:24 +00:00
i2p_domain = args.i2p_domain
2021-12-30 13:56:38 +00:00
set_config_param(base_dir, 'i2pDomain', i2p_domain)
2019-11-11 17:49:08 +00:00
if not args.language:
2021-12-26 14:08:58 +00:00
languageCode = get_config_param(base_dir, 'language')
2019-11-11 17:49:08 +00:00
if languageCode:
2020-04-03 10:08:04 +00:00
args.language = languageCode
2021-07-18 09:55:49 +00:00
else:
args.language = 'en'
2019-11-11 17:49:08 +00:00
2019-08-08 10:50:58 +00:00
# maximum number of new registrations
if not args.maxRegistrations:
2021-12-26 14:08:58 +00:00
maxRegistrations = get_config_param(base_dir, 'maxRegistrations')
2019-08-08 10:50:58 +00:00
if not maxRegistrations:
2020-04-03 10:08:04 +00:00
maxRegistrations = 10
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'maxRegistrations', str(maxRegistrations))
2019-08-08 10:50:58 +00:00
else:
2020-04-03 10:08:04 +00:00
maxRegistrations = int(maxRegistrations)
2019-08-08 10:50:58 +00:00
else:
2020-04-03 10:08:04 +00:00
maxRegistrations = args.maxRegistrations
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'maxRegistrations', str(maxRegistrations))
2019-07-19 18:12:50 +00:00
2019-08-08 10:50:58 +00:00
# if this is the initial run then allow new registrations
2021-12-26 14:08:58 +00:00
if not get_config_param(base_dir, 'registration'):
2021-06-12 22:34:33 +00:00
if args.registration.lower() == 'open':
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'registration', 'open')
set_config_param(base_dir, 'maxRegistrations', str(maxRegistrations))
set_config_param(base_dir, 'registrationsRemaining',
str(maxRegistrations))
2019-08-08 10:50:58 +00:00
2020-03-22 21:16:02 +00:00
if args.resetregistrations:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'registrationsRemaining', str(maxRegistrations))
2020-04-03 10:08:04 +00:00
print('Number of new registrations reset to ' + str(maxRegistrations))
2020-03-22 21:16:02 +00:00
2019-08-02 12:49:34 +00:00
# unique ID for the instance
2021-12-30 13:56:38 +00:00
instance_id = get_config_param(base_dir, 'instanceId')
2021-12-25 20:36:53 +00:00
if not instance_id:
2021-12-28 21:36:27 +00:00
instance_id = create_password(32)
2021-12-30 13:56:38 +00:00
set_config_param(base_dir, 'instanceId', instance_id)
2021-12-25 20:36:53 +00:00
print('Instance ID: ' + instance_id)
2019-08-02 12:49:34 +00:00
2019-07-05 09:20:54 +00:00
# get domain name from configuration
2021-12-26 14:08:58 +00:00
configDomain = get_config_param(base_dir, 'domain')
2019-07-05 09:20:54 +00:00
if configDomain:
2020-04-03 10:08:04 +00:00
domain = configDomain
2019-07-05 09:20:54 +00:00
else:
2020-04-03 10:08:04 +00:00
domain = 'localhost'
2019-07-05 09:20:54 +00:00
# get onion domain name from configuration
2021-12-26 14:08:58 +00:00
configOnionDomain = get_config_param(base_dir, 'onion')
if configOnionDomain:
2021-12-25 20:43:43 +00:00
onion_domain = configOnionDomain
else:
2021-12-25 20:43:43 +00:00
onion_domain = None
# get i2p domain name from configuration
2021-12-30 13:56:38 +00:00
configi2p_domain = get_config_param(base_dir, 'i2pDomain')
2021-12-25 20:50:24 +00:00
if configi2p_domain:
i2p_domain = configi2p_domain
else:
2021-12-25 20:50:24 +00:00
i2p_domain = None
2019-07-05 09:20:54 +00:00
# get port number from configuration
2021-12-26 14:08:58 +00:00
configPort = get_config_param(base_dir, 'port')
2019-07-05 09:20:54 +00:00
if configPort:
2020-04-03 10:08:04 +00:00
port = configPort
2019-07-05 09:20:54 +00:00
else:
2021-02-02 12:25:30 +00:00
if domain.endswith('.onion') or \
domain.endswith('.i2p'):
port = 80
else:
port = 443
2019-07-05 09:20:54 +00:00
2021-12-30 13:56:38 +00:00
configProxyPort = get_config_param(base_dir, 'proxyPort')
2019-08-14 13:52:19 +00:00
if configProxyPort:
2021-12-25 20:58:07 +00:00
proxy_port = configProxyPort
2019-08-14 13:52:19 +00:00
else:
2021-12-25 20:58:07 +00:00
proxy_port = port
2019-08-14 13:52:19 +00:00
2020-04-03 10:08:04 +00:00
nickname = None
2019-07-09 15:51:31 +00:00
if args.nickname:
2020-04-03 10:08:04 +00:00
nickname = nickname
2019-07-09 15:51:31 +00:00
2021-12-25 23:45:30 +00:00
federation_list = []
if args.federation_list:
if len(args.federation_list) == 1:
if not (args.federation_list[0].lower() == 'any' or
args.federation_list[0].lower() == 'all' or
args.federation_list[0].lower() == '*'):
for federationDomain in args.federation_list:
2019-07-09 15:51:31 +00:00
if '@' in federationDomain:
2020-04-03 10:08:04 +00:00
print(federationDomain +
': Federate with domains, not individual accounts')
2019-07-09 15:51:31 +00:00
sys.exit()
2021-12-25 23:45:30 +00:00
federation_list = args.federation_list.copy()
2021-12-30 13:56:38 +00:00
set_config_param(base_dir, 'federationList', federation_list)
2019-07-09 15:51:31 +00:00
else:
2021-12-30 13:56:38 +00:00
configFederationList = get_config_param(base_dir, 'federationList')
2019-07-09 15:51:31 +00:00
if configFederationList:
2021-12-25 23:45:30 +00:00
federation_list = configFederationList
2019-07-09 15:51:31 +00:00
2021-12-25 21:09:22 +00:00
proxy_type = None
2020-06-09 11:03:59 +00:00
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2020-06-09 11:03:59 +00:00
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2020-06-09 11:51:51 +00:00
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
2019-07-09 15:58:51 +00:00
if args.approve:
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
2019-07-20 14:01:07 +00:00
if '@' not in args.approve:
print('syntax: --approve nick@domain')
sys.exit()
session_onion = None
session_i2p = None
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 21:37:41 +00:00
send_threads = []
2020-04-03 10:08:04 +00:00
postLog = []
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2021-12-25 22:17:49 +00:00
person_cache = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
onion_domain = get_config_param(base_dir, 'onionDomain')
if args.onion:
onion_domain = args.onion
if onion_domain:
session_onion = create_session('tor')
i2p_domain = get_config_param(base_dir, 'i2pDomain')
if args.i2p_domain:
i2p_domain = args.i2p_domain
if i2p_domain:
session_i2p = create_session('i2p')
manual_approve_follow_request(session, session_onion, session_i2p,
onion_domain, i2p_domain,
base_dir, http_prefix,
2021-12-29 21:55:09 +00:00
args.nickname, domain, port,
args.approve,
federation_list,
send_threads, postLog,
cached_webfingers, person_cache,
debug, __version__,
signing_priv_key_pem)
sys.exit()
if args.deny:
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
2019-07-20 14:01:07 +00:00
if '@' not in args.deny:
print('syntax: --deny nick@domain')
sys.exit()
session_onion = None
session_i2p = None
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 21:37:41 +00:00
send_threads = []
2020-04-03 10:08:04 +00:00
postLog = []
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2021-12-25 22:17:49 +00:00
person_cache = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
onion_domain = get_config_param(base_dir, 'onionDomain')
if args.onion:
onion_domain = args.onion
if onion_domain:
session_onion = create_session('tor')
i2p_domain = get_config_param(base_dir, 'i2pDomain')
if args.i2p_domain:
i2p_domain = args.i2p_domain
if i2p_domain:
session_i2p = create_session('i2p')
manual_deny_follow_request(session, session_onion, session_i2p,
onion_domain, i2p_domain,
base_dir, http_prefix,
2021-12-29 21:55:09 +00:00
args.nickname, domain, port,
args.deny,
federation_list,
send_threads, postLog,
cached_webfingers, person_cache,
debug, __version__,
signing_priv_key_pem)
sys.exit()
if args.followerspending:
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
2022-01-04 21:19:06 +00:00
accounts_dir = acct_dir(base_dir, args.nickname, domain)
approve_follows_filename = accounts_dir + '/followrequests.txt'
approve_ctr = 0
if os.path.isfile(approve_follows_filename):
with open(approve_follows_filename, 'r') as approvefile:
for approve in approvefile:
2020-05-22 11:32:38 +00:00
print(approve.replace('\n', '').replace('\r', ''))
2022-01-04 21:19:06 +00:00
approve_ctr += 1
if approve_ctr == 0:
print('There are no follow requests pending approval.')
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-16 16:43:28 +00:00
if args.message:
2019-07-19 18:12:50 +00:00
if not args.nickname:
2019-07-16 16:43:28 +00:00
print('Specify a nickname with the --nickname option')
sys.exit()
2020-03-22 21:16:02 +00:00
if args.eventDate:
if '-' not in args.eventDate or len(args.eventDate) != 10:
print('Event date format should be YYYY-MM-DD')
sys.exit()
if args.eventTime:
if ':' not in args.eventTime or len(args.eventTime) != 5:
print('Event time format should be HH:MM')
sys.exit()
2019-07-16 16:43:28 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-03-22 21:16:02 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2019-07-16 16:43:28 +00:00
if not args.sendto:
print('Specify an account to sent to: --sendto [nickname@domain]')
2020-03-22 21:16:02 +00:00
sys.exit()
2019-07-17 14:43:51 +00:00
if '@' not in args.sendto and \
not args.sendto.lower().endswith('public') and \
not args.sendto.lower().endswith('followers'):
2019-07-16 16:43:28 +00:00
print('syntax: --sendto [nickname@domain]')
2019-07-17 14:43:51 +00:00
print(' --sendto public')
print(' --sendto followers')
2019-07-12 22:29:10 +00:00
sys.exit()
2019-07-17 14:43:51 +00:00
if '@' in args.sendto:
2022-01-04 21:19:06 +00:00
to_nickname = args.sendto.split('@')[0]
to_domain = args.sendto.split('@')[1]
to_domain = to_domain.replace('\n', '').replace('\r', '')
to_port = 443
if ':' in to_domain:
to_port = get_port_from_domain(to_domain)
to_domain = remove_domain_port(to_domain)
2019-07-17 14:43:51 +00:00
else:
if args.sendto.endswith('followers'):
2022-01-04 21:19:06 +00:00
to_nickname = None
to_domain = 'followers'
to_port = port
2019-07-17 14:43:51 +00:00
else:
2022-01-04 21:19:06 +00:00
to_nickname = None
to_domain = 'public'
to_port = port
2020-04-03 10:08:04 +00:00
2022-01-04 21:19:06 +00:00
cc_url = None
2020-04-03 10:08:04 +00:00
sendMessage = args.message
2022-01-04 21:19:06 +00:00
followers_only = args.followersonly
2021-12-25 20:39:35 +00:00
client_to_server = args.client
2022-01-04 21:19:06 +00:00
attached_image_description = args.imageDescription
2021-05-09 19:29:53 +00:00
city = 'London, England'
2021-12-25 21:37:41 +00:00
send_threads = []
2020-04-03 10:08:04 +00:00
postLog = []
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2020-04-03 10:08:04 +00:00
subject = args.subject
attach = args.attach
2022-01-04 21:19:06 +00:00
media_type = None
2019-08-30 15:50:20 +00:00
if attach:
2022-01-04 21:19:06 +00:00
media_type = get_attachment_media_type(attach)
reply_to = args.replyto
followers_only = False
is_article = False
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
if args.languages_understood:
languages_understood = [args.languages_understood]
2022-02-24 14:59:10 +00:00
2020-04-03 10:08:04 +00:00
print('Sending post to ' + args.sendto)
2021-12-29 21:55:09 +00:00
send_post_via_server(signing_priv_key_pem, __version__,
base_dir, session, args.nickname, args.password,
domain, port,
2022-01-04 21:19:06 +00:00
to_nickname, to_domain, to_port, cc_url,
http_prefix, sendMessage, followers_only,
args.commentsEnabled, attach, media_type,
attached_image_description, city,
cached_webfingers, person_cache, is_article,
args.language, languages_understood,
args.low_bandwidth,
args.content_license_url,
args.eventDate, args.eventTime, args.eventLocation,
args.debug,
2022-01-04 21:19:06 +00:00
reply_to, reply_to, args.conversationId, subject)
2019-07-16 16:43:28 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-16 20:08:30 +00:00
2022-02-24 10:18:54 +00:00
if args.dav:
if not args.nickname:
print('Please specify a nickname with --nickname')
sys.exit()
if not args.domain:
print('Please specify a domain with --domain')
sys.exit()
if not args.year:
print('Please specify a year with --year')
sys.exit()
if not args.month:
print('Please specify a month with --month')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
proxy_type = None
if args.tor or domain.endswith('.onion'):
proxy_type = 'tor'
if domain.endswith('.onion'):
args.port = 80
elif args.i2p or domain.endswith('.i2p'):
proxy_type = 'i2p'
if domain.endswith('.i2p'):
args.port = 80
elif args.gnunet:
proxy_type = 'gnunet'
session = create_session(proxy_type)
2022-02-24 17:23:41 +00:00
if args.day:
result = \
dav_day_via_server(session, http_prefix,
args.nickname, args.domain, args.port,
args.debug,
args.year, args.month, args.day,
args.password)
else:
result = \
dav_month_via_server(session, http_prefix,
args.nickname, args.domain, args.port,
args.debug,
args.year, args.month,
args.password)
2022-02-24 10:18:54 +00:00
if result:
print(str(result))
sys.exit()
2019-07-16 20:08:30 +00:00
if args.announce:
2019-07-19 18:12:50 +00:00
if not args.nickname:
2019-07-16 20:08:30 +00:00
print('Specify a nickname with the --nickname option')
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-16 20:08:30 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-03-22 21:16:02 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending announce/repeat of ' + args.announce)
2019-07-16 20:08:30 +00:00
2021-12-29 21:55:09 +00:00
send_announce_via_server(base_dir, session, args.nickname, args.password,
domain, port,
http_prefix, args.announce,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2019-07-16 20:08:30 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2021-03-18 11:03:39 +00:00
if args.box:
if not domain:
print('Specify a domain with the --domain option')
sys.exit()
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-25 21:09:22 +00:00
proxy_type = None
2021-03-18 11:03:39 +00:00
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2021-03-18 11:03:39 +00:00
if domain.endswith('.onion'):
args.port = 80
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2021-03-18 11:03:39 +00:00
if domain.endswith('.i2p'):
args.port = 80
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-03-18 11:03:39 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2022-01-04 21:19:06 +00:00
box_json = c2s_box_json(base_dir, session,
args.nickname, args.password,
domain, port, http_prefix,
args.box, args.pageNumber,
args.debug, signing_priv_key_pem)
if box_json:
pprint(box_json)
2021-03-18 11:03:39 +00:00
else:
print('Box not found: ' + args.box)
sys.exit()
2019-07-23 21:45:53 +00:00
if args.itemName:
2019-07-23 21:39:07 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2019-07-23 21:39:07 +00:00
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.summary:
2020-04-03 10:08:04 +00:00
print('Specify a description for your shared item ' +
'with the --summary option')
2019-07-23 21:39:07 +00:00
sys.exit()
2021-07-24 11:30:46 +00:00
if not args.itemQty:
print('Specify a quantity of shared items with the --itemQty option')
sys.exit()
2019-07-23 21:39:07 +00:00
if not args.itemType:
print('Specify a type of shared item with the --itemType option')
sys.exit()
if not args.itemCategory:
2020-04-03 10:08:04 +00:00
print('Specify a category of shared item ' +
'with the --itemCategory option')
2019-07-23 21:39:07 +00:00
sys.exit()
if not args.location:
2021-08-09 19:46:21 +00:00
print('Specify a location or city where the shared ' +
2020-04-03 10:08:04 +00:00
'item resides with the --location option')
2019-07-23 21:39:07 +00:00
sys.exit()
if not args.duration:
2020-04-03 10:08:04 +00:00
print('Specify a duration to share the object ' +
'with the --duration option')
sys.exit()
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending shared item: ' + args.itemName)
2021-12-29 21:55:09 +00:00
send_share_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix,
args.itemName,
args.summary,
args.itemImage,
args.itemQty,
args.itemType,
args.itemCategory,
args.location,
args.duration,
cached_webfingers, person_cache,
debug, __version__,
args.itemPrice, args.itemCurrency,
signing_priv_key_pem)
2019-07-23 21:39:07 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-23 21:45:53 +00:00
if args.undoItemName:
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2019-07-23 21:45:53 +00:00
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending undo of shared item: ' + args.undoItemName)
2019-07-23 21:45:53 +00:00
2021-12-29 21:55:09 +00:00
send_undo_share_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix,
args.undoItemName,
cached_webfingers, person_cache,
debug, __version__, signing_priv_key_pem)
2019-07-23 21:45:53 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2021-08-09 19:46:21 +00:00
if args.wantedItemName:
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.summary:
print('Specify a description for your shared item ' +
'with the --summary option')
sys.exit()
if not args.itemQty:
print('Specify a quantity of shared items with the --itemQty option')
sys.exit()
if not args.itemType:
print('Specify a type of shared item with the --itemType option')
sys.exit()
if not args.itemCategory:
print('Specify a category of shared item ' +
'with the --itemCategory option')
sys.exit()
if not args.location:
print('Specify a location or city where the wanted ' +
'item resides with the --location option')
sys.exit()
if not args.duration:
print('Specify a duration to share the object ' +
'with the --duration option')
sys.exit()
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-08-09 19:46:21 +00:00
print('Sending wanted item: ' + args.wantedItemName)
2021-12-29 21:55:09 +00:00
send_wanted_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix,
args.wantedItemName,
args.summary,
args.itemImage,
args.itemQty,
args.itemType,
args.itemCategory,
args.location,
args.duration,
cached_webfingers, person_cache,
debug, __version__,
args.itemPrice, args.itemCurrency,
signing_priv_key_pem)
2021-08-09 19:46:21 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
if args.undoWantedItemName:
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-08-09 19:46:21 +00:00
print('Sending undo of wanted item: ' + args.undoWantedItemName)
2021-12-29 21:55:09 +00:00
send_undo_wanted_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix,
args.undoWantedItemName,
cached_webfingers, person_cache,
debug, __version__, signing_priv_key_pem)
2021-08-09 19:46:21 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-17 18:33:41 +00:00
if args.like:
2019-07-19 18:12:50 +00:00
if not args.nickname:
2019-07-17 18:33:41 +00:00
print('Specify a nickname with the --nickname option')
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-17 18:33:41 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-03-22 21:16:02 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending like of ' + args.like)
2019-07-17 18:33:41 +00:00
2021-12-29 21:55:09 +00:00
send_like_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix, args.like,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2019-07-17 18:33:41 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2021-11-10 12:16:03 +00:00
if args.react:
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.emoji:
print('Specify a reaction emoji with the --emoji option')
sys.exit()
2021-12-29 21:55:09 +00:00
if not valid_emoji_content(args.emoji):
2021-11-10 13:10:02 +00:00
print('This is not a valid emoji')
sys.exit()
2021-11-10 12:16:03 +00:00
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2021-11-10 12:16:03 +00:00
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-11-10 12:16:03 +00:00
print('Sending emoji reaction ' + args.emoji + ' to ' + args.react)
2021-12-29 21:55:09 +00:00
send_reaction_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix, args.react, args.emoji,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2021-11-10 12:16:03 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-17 19:04:00 +00:00
if args.undolike:
2019-07-19 18:12:50 +00:00
if not args.nickname:
2019-07-17 19:04:00 +00:00
print('Specify a nickname with the --nickname option')
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-17 19:04:00 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-03-22 21:16:02 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending undo like of ' + args.undolike)
2019-07-17 19:04:00 +00:00
2021-12-29 21:55:09 +00:00
send_undo_like_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix, args.undolike,
cached_webfingers, person_cache,
True, __version__,
signing_priv_key_pem)
2019-07-17 19:04:00 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2021-11-10 12:16:03 +00:00
if args.undoreact:
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.emoji:
print('Specify a reaction emoji with the --emoji option')
sys.exit()
2021-12-29 21:55:09 +00:00
if not valid_emoji_content(args.emoji):
2021-11-10 13:10:02 +00:00
print('This is not a valid emoji')
sys.exit()
2021-11-10 12:16:03 +00:00
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2021-11-10 12:16:03 +00:00
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-11-10 12:16:03 +00:00
print('Sending undo emoji reaction ' + args.emoji + ' to ' + args.react)
2021-12-29 21:55:09 +00:00
send_undo_reaction_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix, args.undoreact, args.emoji,
cached_webfingers, person_cache,
True, __version__,
signing_priv_key_pem)
2021-11-10 12:16:03 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2021-03-20 10:43:52 +00:00
if args.bookmark:
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-03-20 10:43:52 +00:00
print('Sending bookmark of ' + args.bookmark)
2021-12-29 21:55:09 +00:00
send_bookmark_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix, args.bookmark,
cached_webfingers, person_cache,
True, __version__,
signing_priv_key_pem)
2021-03-20 10:43:52 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
if args.unbookmark:
if not args.nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-03-20 10:43:52 +00:00
print('Sending undo bookmark of ' + args.unbookmark)
2021-12-29 21:55:09 +00:00
send_undo_bookmark_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix, args.unbookmark,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2021-03-20 10:43:52 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-17 17:29:33 +00:00
if args.delete:
2019-07-19 18:12:50 +00:00
if not args.nickname:
2019-07-17 17:29:33 +00:00
print('Specify a nickname with the --nickname option')
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-17 17:29:33 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-03-22 21:16:02 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending delete request of ' + args.delete)
2019-07-17 17:29:33 +00:00
2021-12-29 21:55:09 +00:00
send_delete_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
http_prefix, args.delete,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2019-07-17 17:29:33 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-17 12:17:54 +00:00
if args.follow:
# follow via c2s protocol
2019-07-17 12:25:02 +00:00
if '.' not in args.follow:
print("This doesn't look like a fediverse handle")
sys.exit()
2019-07-19 18:12:50 +00:00
if not args.nickname:
2019-07-17 12:17:54 +00:00
print('Please specify the nickname for the account with --nickname')
sys.exit()
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-03-22 21:16:02 +00:00
2022-01-04 21:19:06 +00:00
follow_nickname = get_nickname_from_actor(args.follow)
if not follow_nickname:
2020-04-03 10:08:04 +00:00
print('Unable to find nickname in ' + args.follow)
2020-03-22 21:16:02 +00:00
sys.exit()
2022-01-04 21:19:06 +00:00
follow_domain, follow_port = get_domain_from_actor(args.follow)
2019-07-09 15:51:31 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2022-01-04 21:19:06 +00:00
follow_http_prefix = http_prefix
2019-07-09 15:51:31 +00:00
if args.follow.startswith('https'):
2022-01-04 21:19:06 +00:00
follow_http_prefix = 'https'
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
2021-12-28 20:32:11 +00:00
send_follow_requestViaServer(base_dir, session,
args.nickname, args.password,
domain, port,
2022-01-04 21:19:06 +00:00
follow_nickname, follow_domain, follow_port,
follow_http_prefix,
2021-12-28 20:32:11 +00:00
cached_webfingers, person_cache,
debug, __version__, signing_priv_key_pem)
2019-07-17 12:17:54 +00:00
for t in range(20):
2019-07-09 15:51:31 +00:00
time.sleep(1)
2019-07-17 12:17:54 +00:00
# TODO some method to know if it worked
2019-07-17 12:25:02 +00:00
print('Ok')
2019-07-09 15:51:31 +00:00
sys.exit()
2019-07-17 12:25:02 +00:00
if args.unfollow:
# unfollow via c2s protocol
if '.' not in args.follow:
print("This doesn't look like a fediverse handle")
sys.exit()
2019-07-19 18:12:50 +00:00
if not args.nickname:
2019-07-17 12:25:02 +00:00
print('Please specify the nickname for the account with --nickname')
sys.exit()
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-03-22 21:16:02 +00:00
2022-01-04 21:19:06 +00:00
follow_nickname = get_nickname_from_actor(args.unfollow)
if not follow_nickname:
2020-04-03 10:08:04 +00:00
print('WARN: unable to find nickname in ' + args.unfollow)
2020-03-22 21:16:02 +00:00
sys.exit()
2022-01-04 21:19:06 +00:00
follow_domain, follow_port = get_domain_from_actor(args.unfollow)
2019-07-17 12:25:02 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2022-01-04 21:19:06 +00:00
follow_http_prefix = http_prefix
2019-07-17 12:25:02 +00:00
if args.follow.startswith('https'):
2022-01-04 21:19:06 +00:00
follow_http_prefix = 'https'
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
2021-12-29 21:55:09 +00:00
send_unfollow_request_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
2022-01-04 21:19:06 +00:00
follow_nickname, follow_domain,
follow_port, follow_http_prefix,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
debug, __version__, signing_priv_key_pem)
2019-07-17 12:25:02 +00:00
for t in range(20):
time.sleep(1)
# TODO some method to know if it worked
print('Ok')
sys.exit()
2021-03-24 13:52:20 +00:00
if args.followingList:
2021-03-24 12:43:24 +00:00
# following list via c2s protocol
if not args.nickname:
print('Please specify the nickname for the account with --nickname')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2022-01-04 21:19:06 +00:00
follow_http_prefix = http_prefix
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-03-24 12:43:24 +00:00
2022-01-04 21:19:06 +00:00
following_json = \
2021-12-29 21:55:09 +00:00
get_following_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
2022-01-04 21:19:06 +00:00
follow_http_prefix, args.pageNumber,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
debug, __version__, signing_priv_key_pem)
2022-01-04 21:19:06 +00:00
if following_json:
pprint(following_json)
2021-03-24 12:43:24 +00:00
sys.exit()
2021-03-24 13:52:20 +00:00
if args.followersList:
# following list via c2s protocol
if not args.nickname:
print('Please specify the nickname for the account with --nickname')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2022-01-04 21:19:06 +00:00
follow_http_prefix = http_prefix
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-03-24 13:52:20 +00:00
2022-01-04 21:19:06 +00:00
followers_json = \
2021-12-29 21:55:09 +00:00
get_followers_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
2022-01-04 21:19:06 +00:00
follow_http_prefix, args.pageNumber,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
debug, __version__,
signing_priv_key_pem)
2022-01-04 21:19:06 +00:00
if followers_json:
pprint(followers_json)
2021-03-24 13:52:20 +00:00
sys.exit()
if args.followRequestsList:
# follow requests list via c2s protocol
if not args.nickname:
print('Please specify the nickname for the account with --nickname')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2022-01-04 21:19:06 +00:00
follow_http_prefix = http_prefix
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2022-01-04 21:19:06 +00:00
follow_requests_json = \
2021-12-29 21:55:09 +00:00
get_follow_requests_via_server(base_dir, session,
args.nickname, args.password,
domain, port,
2022-01-04 21:19:06 +00:00
follow_http_prefix, args.pageNumber,
2021-12-29 21:55:09 +00:00
cached_webfingers, person_cache,
debug, __version__,
signing_priv_key_pem)
2022-01-04 21:19:06 +00:00
if follow_requests_json:
pprint(follow_requests_json)
sys.exit()
2020-04-03 10:08:04 +00:00
nickname = 'admin'
2019-07-05 09:20:54 +00:00
if args.domain:
2020-04-03 10:08:04 +00:00
domain = args.domain
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'domain', domain)
2019-07-05 09:20:54 +00:00
if args.port:
2020-04-03 10:08:04 +00:00
port = args.port
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'port', port)
2021-12-25 20:58:07 +00:00
if args.proxy_port:
proxy_port = args.proxy_port
2021-12-30 13:56:38 +00:00
set_config_param(base_dir, 'proxyPort', proxy_port)
2020-06-09 11:51:51 +00:00
if args.gnunet:
2021-12-25 17:09:22 +00:00
http_prefix = 'gnunet'
2021-07-01 17:59:24 +00:00
if args.dat or args.hyper:
2021-12-25 17:09:22 +00:00
http_prefix = 'hyper'
2020-02-17 17:18:21 +00:00
if args.i2p:
2021-12-25 17:09:22 +00:00
http_prefix = 'http'
2019-07-04 22:44:32 +00:00
if args.migrations:
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if args.http or domain.endswith('.onion'):
2021-12-25 17:09:22 +00:00
http_prefix = 'http'
port = 80
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
elif domain.endswith('.i2p'):
2021-12-25 17:09:22 +00:00
http_prefix = 'http'
port = 80
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
elif args.gnunet:
2021-12-25 17:09:22 +00:00
http_prefix = 'gnunet'
port = 80
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
else:
2021-12-25 17:09:22 +00:00
http_prefix = 'https'
port = 443
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-12-29 21:55:09 +00:00
ctr = migrate_accounts(base_dir, session,
http_prefix, cached_webfingers,
True, signing_priv_key_pem)
if ctr == 0:
print('No followed accounts have moved')
else:
print(str(ctr) + ' followed accounts were migrated')
sys.exit()
2019-07-05 15:53:26 +00:00
if args.actor:
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-09-01 17:48:44 +00:00
if debug:
2021-12-25 16:17:53 +00:00
print('base_dir: ' + str(base_dir))
2021-12-25 23:03:28 +00:00
if signing_priv_key_pem:
2021-09-01 17:48:44 +00:00
print('Obtained instance actor signing key')
else:
print('Did not obtain instance actor key for ' + domain)
2021-12-29 21:55:09 +00:00
get_actor_json(domain, args.actor, args.http, args.gnunet,
debug, False, signing_priv_key_pem, None)
2019-07-05 15:53:26 +00:00
sys.exit()
2021-01-10 21:38:28 +00:00
if args.followers:
originalActor = args.followers
if '/@' in args.followers or \
'/users/' in args.followers or \
args.followers.startswith('http') or \
2021-07-01 17:59:24 +00:00
args.followers.startswith('hyper'):
2021-01-10 21:38:28 +00:00
# format: https://domain/@nick
2021-12-27 17:20:01 +00:00
prefixes = get_protocol_prefixes()
2021-01-10 21:38:28 +00:00
for prefix in prefixes:
args.followers = args.followers.replace(prefix, '')
args.followers = args.followers.replace('/@', '/users/')
2021-12-26 12:19:00 +00:00
if not has_users_path(args.followers):
2021-01-10 21:38:28 +00:00
print('Expected actor format: ' +
'https://domain/@nick or https://domain/users/nick')
sys.exit()
if '/users/' in args.followers:
nickname = args.followers.split('/users/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
domain = args.followers.split('/users/')[0]
elif '/profile/' in args.followers:
nickname = args.followers.split('/profile/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
domain = args.followers.split('/profile/')[0]
elif '/channel/' in args.followers:
nickname = args.followers.split('/channel/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
domain = args.followers.split('/channel/')[0]
elif '/accounts/' in args.followers:
nickname = args.followers.split('/accounts/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
domain = args.followers.split('/accounts/')[0]
2021-02-09 17:00:35 +00:00
elif '/u/' in args.followers:
nickname = args.followers.split('/u/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
domain = args.followers.split('/u/')[0]
2021-07-29 17:14:33 +00:00
elif '/c/' in args.followers:
nickname = args.followers.split('/c/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
domain = args.followers.split('/c/')[0]
2021-01-10 21:38:28 +00:00
else:
# format: @nick@domain
if '@' not in args.followers:
print('Syntax: --actor nickname@domain')
sys.exit()
if args.followers.startswith('@'):
args.followers = args.followers[1:]
if '@' not in args.followers:
print('Syntax: --actor nickname@domain')
sys.exit()
nickname = args.followers.split('@')[0]
domain = args.followers.split('@')[1]
domain = domain.replace('\n', '').replace('\r', '')
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
2021-01-10 21:38:28 +00:00
if args.http or domain.endswith('.onion'):
2021-12-25 17:09:22 +00:00
http_prefix = 'http'
2021-01-10 21:38:28 +00:00
port = 80
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2021-01-10 21:38:28 +00:00
elif domain.endswith('.i2p'):
2021-12-25 17:09:22 +00:00
http_prefix = 'http'
2021-01-10 21:38:28 +00:00
port = 80
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2021-01-10 21:38:28 +00:00
elif args.gnunet:
2021-12-25 17:09:22 +00:00
http_prefix = 'gnunet'
2021-01-10 21:38:28 +00:00
port = 80
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
2021-01-10 21:38:28 +00:00
else:
2021-12-25 17:09:22 +00:00
http_prefix = 'https'
2021-01-10 21:38:28 +00:00
port = 443
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-01-10 21:38:28 +00:00
if nickname == 'inbox':
nickname = domain
2021-09-08 12:34:13 +00:00
hostDomain = None
if args.domain:
hostDomain = args.domain
2021-01-10 21:38:28 +00:00
handle = nickname + '@' + domain
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2022-01-02 14:51:02 +00:00
wf_request = webfinger_handle(session, handle,
http_prefix, cached_webfingers,
hostDomain, __version__, debug, False,
signing_priv_key_pem)
if not wf_request:
2021-01-10 21:38:28 +00:00
print('Unable to webfinger ' + handle)
sys.exit()
2022-01-02 14:51:02 +00:00
if not isinstance(wf_request, dict):
2021-01-10 21:38:28 +00:00
print('Webfinger for ' + handle + ' did not return a dict. ' +
2022-01-02 14:51:02 +00:00
str(wf_request))
2021-01-10 21:38:28 +00:00
sys.exit()
2022-01-04 21:19:06 +00:00
person_url = None
2022-01-02 14:51:02 +00:00
if wf_request.get('errors'):
print('wf_request error: ' + str(wf_request['errors']))
2021-12-26 12:19:00 +00:00
if has_users_path(args.followers):
2022-01-04 21:19:06 +00:00
person_url = originalActor
2021-01-10 21:38:28 +00:00
else:
sys.exit()
2022-01-04 21:19:06 +00:00
profile_str = 'https://www.w3.org/ns/activitystreams'
as_header = {
'Accept': 'application/activity+json; profile="' + profile_str + '"'
2021-01-10 21:38:28 +00:00
}
2022-01-04 21:19:06 +00:00
if not person_url:
person_url = get_user_url(wf_request, 0, args.debug)
2021-01-10 21:38:28 +00:00
if nickname == domain:
2022-01-04 21:19:06 +00:00
person_url = person_url.replace('/users/', '/actor/')
person_url = person_url.replace('/accounts/', '/actor/')
person_url = person_url.replace('/channel/', '/actor/')
person_url = person_url.replace('/profile/', '/actor/')
person_url = person_url.replace('/u/', '/actor/')
person_url = person_url.replace('/c/', '/actor/')
if not person_url:
2021-01-10 21:38:28 +00:00
# try single user instance
2022-01-04 21:19:06 +00:00
person_url = http_prefix + '://' + domain
profile_str = 'https://www.w3.org/ns/activitystreams'
as_header = {
'Accept': 'application/ld+json; profile="' + profile_str + '"'
2021-01-10 21:38:28 +00:00
}
2022-01-04 21:19:06 +00:00
if '/channel/' in person_url or '/accounts/' in person_url:
profile_str = 'https://www.w3.org/ns/activitystreams'
as_header = {
'Accept': 'application/ld+json; profile="' + profile_str + '"'
2021-01-10 21:38:28 +00:00
}
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2022-01-04 21:19:06 +00:00
followers_list = \
2021-12-29 21:55:09 +00:00
download_follow_collection(signing_priv_key_pem,
'followers', session,
2022-01-04 21:19:06 +00:00
http_prefix, person_url, 1, 3, args.debug)
if followers_list:
for actor in followers_list:
2021-01-10 21:38:28 +00:00
print(actor)
sys.exit()
2019-07-04 22:44:32 +00:00
if args.addaccount:
if '@' in args.addaccount:
2020-04-03 10:08:04 +00:00
nickname = args.addaccount.split('@')[0]
domain = args.addaccount.split('@')[1]
2019-07-04 22:44:32 +00:00
else:
2020-04-03 10:08:04 +00:00
nickname = args.addaccount
2021-12-26 14:08:58 +00:00
if not args.domain or not get_config_param(base_dir, 'domain'):
2019-07-04 22:44:32 +00:00
print('Use the --domain option to set the domain name')
sys.exit()
2022-01-04 21:19:06 +00:00
configured_domain = get_config_param(base_dir, 'domain')
if configured_domain:
if domain != configured_domain:
print('The account domain is expected to be ' + configured_domain)
sys.exit()
2021-12-28 14:41:10 +00:00
if not valid_nickname(domain, nickname):
2020-04-03 10:08:04 +00:00
print(nickname + ' is a reserved name. Use something different.')
2020-03-22 21:16:02 +00:00
sys.exit()
2021-03-13 11:49:05 +00:00
2019-07-05 09:20:54 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-04-03 10:08:04 +00:00
if len(args.password.strip()) < 8:
2019-07-05 09:20:54 +00:00
print('Password should be at least 8 characters')
2020-03-22 21:16:02 +00:00
sys.exit()
2022-01-04 21:19:06 +00:00
account_dir = acct_dir(base_dir, nickname, domain)
if os.path.isdir(account_dir):
2019-07-04 22:50:40 +00:00
print('Account already exists')
sys.exit()
2021-12-25 16:17:53 +00:00
if os.path.isdir(base_dir + '/deactivated/' + nickname + '@' + domain):
print('Account is deactivated')
sys.exit()
2021-02-02 11:47:49 +00:00
if domain.endswith('.onion') or \
domain.endswith('.i2p'):
2021-02-02 12:25:30 +00:00
port = 80
2021-12-25 17:09:22 +00:00
http_prefix = 'http'
2021-12-29 21:55:09 +00:00
create_person(base_dir, nickname, domain, port, http_prefix,
True, not args.noapproval, args.password.strip())
2022-01-04 21:19:06 +00:00
if os.path.isdir(account_dir):
2020-04-03 10:08:04 +00:00
print('Account created for ' + nickname + '@' + domain)
2019-07-05 09:20:54 +00:00
else:
print('Account creation failed')
2019-07-04 22:44:32 +00:00
sys.exit()
2019-10-04 12:39:46 +00:00
if args.addgroup:
if '@' in args.addgroup:
2020-04-03 10:08:04 +00:00
nickname = args.addgroup.split('@')[0]
domain = args.addgroup.split('@')[1]
2019-10-04 12:39:46 +00:00
else:
2020-04-03 10:08:04 +00:00
nickname = args.addgroup
2021-12-26 14:08:58 +00:00
if not args.domain or not get_config_param(base_dir, 'domain'):
2019-10-04 12:39:46 +00:00
print('Use the --domain option to set the domain name')
sys.exit()
2021-07-30 11:28:57 +00:00
if nickname.startswith('!'):
# remove preceding group indicator
nickname = nickname[1:]
2021-12-28 14:41:10 +00:00
if not valid_nickname(domain, nickname):
2020-04-03 10:08:04 +00:00
print(nickname + ' is a reserved name. Use something different.')
2019-10-04 12:39:46 +00:00
sys.exit()
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2020-04-03 10:08:04 +00:00
if len(args.password.strip()) < 8:
2019-10-04 12:39:46 +00:00
print('Password should be at least 8 characters')
sys.exit()
2022-01-04 21:19:06 +00:00
account_dir = acct_dir(base_dir, nickname, domain)
if os.path.isdir(account_dir):
2019-10-04 12:39:46 +00:00
print('Group already exists')
sys.exit()
2021-12-29 21:55:09 +00:00
create_group(base_dir, nickname, domain, port, http_prefix,
True, args.password.strip())
2022-01-04 21:19:06 +00:00
if os.path.isdir(account_dir):
2020-04-03 10:08:04 +00:00
print('Group created for ' + nickname + '@' + domain)
2019-10-04 12:39:46 +00:00
else:
print('Group creation failed')
sys.exit()
2019-10-04 12:59:31 +00:00
if args.rmgroup:
2020-04-03 10:08:04 +00:00
args.rmaccount = args.rmgroup
2019-10-04 12:59:31 +00:00
2019-11-05 10:37:37 +00:00
if args.deactivate:
2020-04-03 10:08:04 +00:00
args.rmaccount = args.deactivate
2019-11-05 10:37:37 +00:00
2019-07-04 22:50:40 +00:00
if args.rmaccount:
if '@' in args.rmaccount:
2020-04-03 10:08:04 +00:00
nickname = args.rmaccount.split('@')[0]
domain = args.rmaccount.split('@')[1]
2019-07-04 22:50:40 +00:00
else:
2020-04-03 10:08:04 +00:00
nickname = args.rmaccount
2021-12-26 14:08:58 +00:00
if not args.domain or not get_config_param(base_dir, 'domain'):
2019-07-04 22:50:40 +00:00
print('Use the --domain option to set the domain name')
sys.exit()
if args.domain:
domain = args.domain
else:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2022-01-04 21:19:06 +00:00
configured_domain = get_config_param(base_dir, 'domain')
if configured_domain:
if domain != configured_domain:
print('The account domain is expected to be ' + configured_domain)
sys.exit()
2019-11-05 10:37:37 +00:00
if args.deactivate:
2021-12-28 18:13:52 +00:00
if deactivate_account(base_dir, nickname, domain):
2020-04-03 10:08:04 +00:00
print('Account for ' + nickname + '@' + domain +
' was deactivated')
2019-11-05 10:37:37 +00:00
else:
2020-04-03 10:08:04 +00:00
print('Account for ' + nickname + '@' + domain + ' was not found')
2019-11-05 10:37:37 +00:00
sys.exit()
2021-12-28 18:13:52 +00:00
if remove_account(base_dir, nickname, domain, port):
2019-10-04 12:59:31 +00:00
if not args.rmgroup:
2020-04-03 10:08:04 +00:00
print('Account for ' + nickname + '@' + domain + ' was removed')
2019-10-04 12:59:31 +00:00
else:
2020-04-03 10:08:04 +00:00
print('Group ' + nickname + '@' + domain + ' was removed')
2019-10-04 12:59:31 +00:00
sys.exit()
2019-07-04 22:50:40 +00:00
2019-11-05 10:40:44 +00:00
if args.activate:
if '@' in args.activate:
2020-04-03 10:08:04 +00:00
nickname = args.activate.split('@')[0]
domain = args.activate.split('@')[1]
2019-11-05 10:40:44 +00:00
else:
2020-04-03 10:08:04 +00:00
nickname = args.activate
2021-12-26 14:08:58 +00:00
if not args.domain or not get_config_param(base_dir, 'domain'):
2019-11-05 10:40:44 +00:00
print('Use the --domain option to set the domain name')
sys.exit()
2021-12-28 18:13:52 +00:00
if activate_account(base_dir, nickname, domain):
2020-04-03 10:08:04 +00:00
print('Account for ' + nickname + '@' + domain + ' was activated')
2019-11-05 10:40:44 +00:00
else:
2020-04-03 10:08:04 +00:00
print('Deactivated account for ' + nickname + '@' + domain +
' was not found')
2019-11-05 10:40:44 +00:00
sys.exit()
2019-07-05 09:44:15 +00:00
if args.changepassword:
2020-04-03 10:08:04 +00:00
if len(args.changepassword) != 2:
2019-07-05 09:44:15 +00:00
print('--changepassword [nickname] [new password]')
sys.exit()
if '@' in args.changepassword[0]:
2020-04-03 10:08:04 +00:00
nickname = args.changepassword[0].split('@')[0]
domain = args.changepassword[0].split('@')[1]
2019-07-05 09:44:15 +00:00
else:
2020-04-03 10:08:04 +00:00
nickname = args.changepassword[0]
2021-12-26 14:08:58 +00:00
if not args.domain or not get_config_param(base_dir, 'domain'):
2019-07-05 09:44:15 +00:00
print('Use the --domain option to set the domain name')
sys.exit()
2022-01-04 21:19:06 +00:00
new_password = args.changepassword[1]
if len(new_password) < 8:
2019-07-05 09:44:15 +00:00
print('Password should be at least 8 characters')
sys.exit()
2022-01-04 21:19:06 +00:00
account_dir = acct_dir(base_dir, nickname, domain)
if not os.path.isdir(account_dir):
2020-04-03 10:08:04 +00:00
print('Account ' + nickname + '@' + domain + ' not found')
2019-07-05 09:58:58 +00:00
sys.exit()
2022-01-04 21:19:06 +00:00
password_file = base_dir + '/accounts/passwords'
if os.path.isfile(password_file):
if nickname + ':' in open(password_file).read():
store_basic_credentials(base_dir, nickname, new_password)
2020-04-03 10:08:04 +00:00
print('Password for ' + nickname + ' was changed')
2019-07-05 09:44:15 +00:00
else:
2020-04-03 10:08:04 +00:00
print(nickname + ' is not in the passwords file')
2019-07-05 09:44:15 +00:00
else:
print('Passwords file not found')
sys.exit()
2019-07-12 20:51:02 +00:00
if args.archive:
if args.archive.lower().endswith('null') or \
args.archive.lower().endswith('delete') or \
args.archive.lower().endswith('none'):
2020-04-03 10:08:04 +00:00
args.archive = None
2019-07-12 20:51:02 +00:00
print('Archiving with deletion of old posts...')
else:
2020-04-03 10:08:04 +00:00
print('Archiving to ' + args.archive + '...')
2021-12-29 21:55:09 +00:00
archive_media(base_dir, args.archive, args.archiveWeeks)
archive_posts(base_dir, http_prefix, args.archive, {},
args.archiveMaxPosts)
2019-07-12 20:51:02 +00:00
print('Archiving complete')
2019-07-14 15:43:02 +00:00
sys.exit()
2019-07-12 20:51:02 +00:00
2019-07-05 10:03:25 +00:00
if not args.domain and not domain:
2019-07-04 22:44:32 +00:00
print('Specify a domain with --domain [name]')
2019-07-03 09:24:55 +00:00
sys.exit()
2019-07-05 09:44:15 +00:00
2019-07-12 14:31:56 +00:00
if args.avatar:
if not os.path.isfile(args.avatar):
2020-04-03 10:08:04 +00:00
print(args.avatar + ' is not an image filename')
2019-07-12 14:31:56 +00:00
sys.exit()
if not args.nickname:
print('Specify a nickname with --nickname [name]')
sys.exit()
2021-05-09 19:29:53 +00:00
city = 'London, England'
2021-12-29 21:55:09 +00:00
if set_profile_image(base_dir, http_prefix, args.nickname, domain,
port, args.avatar, 'avatar', '128x128', city,
args.content_license_url):
2020-04-03 10:08:04 +00:00
print('Avatar added for ' + args.nickname)
2019-07-12 14:31:56 +00:00
else:
2020-04-03 10:08:04 +00:00
print('Avatar was not added for ' + args.nickname)
2020-03-22 21:16:02 +00:00
sys.exit()
if args.backgroundImage:
if not os.path.isfile(args.backgroundImage):
2020-04-03 10:08:04 +00:00
print(args.backgroundImage + ' is not an image filename')
sys.exit()
if not args.nickname:
print('Specify a nickname with --nickname [name]')
sys.exit()
2021-05-09 19:29:53 +00:00
city = 'London, England'
2021-12-29 21:55:09 +00:00
if set_profile_image(base_dir, http_prefix, args.nickname, domain,
port, args.backgroundImage, 'background',
'256x256', city, args.content_license_url):
2020-04-03 10:08:04 +00:00
print('Background image added for ' + args.nickname)
else:
2020-04-03 10:08:04 +00:00
print('Background image was not added for ' + args.nickname)
2020-03-22 21:16:02 +00:00
sys.exit()
if args.skill:
2019-07-19 10:01:24 +00:00
if not nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-19 10:01:24 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2019-07-19 10:01:24 +00:00
if not args.skillLevelPercent:
print('Specify a skill level in the range 0-100')
sys.exit()
2020-04-03 10:08:04 +00:00
if int(args.skillLevelPercent) < 0 or \
int(args.skillLevelPercent) > 100:
2019-07-19 10:01:24 +00:00
print('Skill level should be a percentage in the range 0-100')
sys.exit()
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending ' + args.skill + ' skill level ' +
str(args.skillLevelPercent) + ' for ' + nickname)
2019-07-19 10:01:24 +00:00
2021-12-29 21:55:09 +00:00
send_skill_via_server(base_dir, session,
nickname, args.password,
domain, port,
http_prefix,
args.skill, args.skillLevelPercent,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2019-07-19 10:01:24 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-19 11:38:37 +00:00
if args.availability:
if not nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-19 11:38:37 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2019-07-19 11:38:37 +00:00
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending availability status of ' + nickname +
' as ' + args.availability)
2019-07-19 11:38:37 +00:00
2021-12-29 21:55:09 +00:00
send_availability_via_server(base_dir, session, nickname, args.password,
2022-01-04 21:19:06 +00:00
domain, port, http_prefix,
2021-12-29 21:55:09 +00:00
args.availability,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2019-07-19 11:38:37 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2021-03-16 22:14:03 +00:00
if args.desktop:
2021-03-01 19:16:33 +00:00
# Announce posts as they arrive in your inbox using text-to-speech
2021-03-16 22:15:49 +00:00
if args.desktop.startswith('@'):
args.desktop = args.desktop[1:]
if '@' not in args.desktop:
print('Specify the handle to notify: nickname@domain')
2021-03-01 19:16:33 +00:00
sys.exit()
2021-03-16 22:15:49 +00:00
nickname = args.desktop.split('@')[0]
domain = args.desktop.split('@')[1]
2021-03-01 19:16:33 +00:00
if not nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.password:
2021-03-13 11:13:35 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
2021-03-01 19:16:33 +00:00
2021-03-13 11:15:52 +00:00
args.password = args.password.replace('\n', '')
2021-12-25 21:09:22 +00:00
proxy_type = None
2021-03-01 19:16:33 +00:00
if args.tor or domain.endswith('.onion'):
2021-12-25 21:09:22 +00:00
proxy_type = 'tor'
2021-03-01 19:16:33 +00:00
if domain.endswith('.onion'):
args.port = 80
elif args.i2p or domain.endswith('.i2p'):
2021-12-25 21:09:22 +00:00
proxy_type = 'i2p'
2021-03-01 19:16:33 +00:00
if domain.endswith('.i2p'):
args.port = 80
elif args.gnunet:
2021-12-25 21:09:22 +00:00
proxy_type = 'gnunet'
2021-03-01 19:16:33 +00:00
# only store inbox posts if we are not running as a daemon
storeInboxPosts = not args.noKeyPress
2021-12-29 21:55:09 +00:00
run_desktop_client(base_dir, proxy_type, http_prefix,
nickname, domain, port, args.password,
args.screenreader, args.language,
args.notificationSounds,
args.notificationType,
args.noKeyPress,
storeInboxPosts,
args.notifyShowNewPosts,
args.language,
args.debug, args.low_bandwidth)
2021-03-01 19:16:33 +00:00
sys.exit()
2021-12-25 23:45:30 +00:00
if federation_list:
print('Federating with: ' + str(federation_list))
2021-12-25 18:05:01 +00:00
if args.shared_items_federated_domains:
print('Federating shared items with: ' +
2021-12-25 18:05:01 +00:00
args.shared_items_federated_domains)
2021-12-25 18:05:01 +00:00
shared_items_federated_domains = []
if args.shared_items_federated_domains:
fed_domains_str = args.shared_items_federated_domains
2021-12-30 13:56:38 +00:00
set_config_param(base_dir, 'sharedItemsFederatedDomains',
2021-12-27 20:38:02 +00:00
fed_domains_str)
else:
2021-12-25 18:05:01 +00:00
fed_domains_str = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'sharedItemsFederatedDomains')
2021-12-25 18:05:01 +00:00
if fed_domains_str:
fed_domains_list = fed_domains_str.split(',')
2022-01-04 21:19:06 +00:00
for shared_federated_domain in fed_domains_list:
shared_items_federated_domains.append(shared_federated_domain.strip())
2019-07-03 12:24:54 +00:00
2019-07-14 19:57:05 +00:00
if args.block:
2019-07-17 22:09:09 +00:00
if not nickname:
print('Specify a nickname with the --nickname option')
2019-07-14 19:57:05 +00:00
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-17 22:09:09 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2019-07-17 22:09:09 +00:00
if '@' in args.block:
2022-01-04 21:19:06 +00:00
blocked_domain = args.block.split('@')[1]
blocked_domain = blocked_domain.replace('\n', '').replace('\r', '')
blocked_nickname = args.block.split('@')[0]
blocked_actor = http_prefix + '://' + blocked_domain + \
'/users/' + blocked_nickname
args.block = blocked_actor
2019-07-17 22:09:09 +00:00
else:
if '/users/' not in args.block:
2020-04-03 10:08:04 +00:00
print(args.block + ' does not look like an actor url')
2019-07-17 22:09:09 +00:00
sys.exit()
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending block of ' + args.block)
2019-07-17 22:09:09 +00:00
2021-12-29 21:55:09 +00:00
send_block_via_server(base_dir, session, nickname, args.password,
domain, port,
http_prefix, args.block,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2019-07-17 22:09:09 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
2019-07-14 19:57:05 +00:00
sys.exit()
2021-03-20 21:20:41 +00:00
if args.mute:
if not nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-03-20 21:20:41 +00:00
print('Sending mute of ' + args.mute)
2021-12-29 21:55:09 +00:00
send_mute_via_server(base_dir, session, nickname, args.password,
domain, port,
http_prefix, args.mute,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2021-03-20 21:20:41 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
if args.unmute:
if not nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.password:
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2021-03-20 21:20:41 +00:00
print('Sending undo mute of ' + args.unmute)
2021-12-29 21:55:09 +00:00
send_undo_mute_via_server(base_dir, session, nickname, args.password,
domain, port,
http_prefix, args.unmute,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2021-03-20 21:20:41 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
sys.exit()
2019-07-14 19:57:05 +00:00
if args.unblock:
2019-07-17 22:09:09 +00:00
if not nickname:
print('Specify a nickname with the --nickname option')
2019-07-14 19:57:05 +00:00
sys.exit()
2020-03-22 21:16:02 +00:00
2019-07-17 22:09:09 +00:00
if not args.password:
2021-03-13 11:49:05 +00:00
args.password = getpass.getpass('Password: ')
if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
2019-07-17 22:09:09 +00:00
if '@' in args.unblock:
2022-01-04 21:19:06 +00:00
blocked_domain = args.unblock.split('@')[1]
blocked_domain = blocked_domain.replace('\n', '').replace('\r', '')
blocked_nickname = args.unblock.split('@')[0]
blocked_actor = http_prefix + '://' + blocked_domain + \
'/users/' + blocked_nickname
args.unblock = blocked_actor
2019-07-17 22:09:09 +00:00
else:
if '/users/' not in args.unblock:
2020-04-03 10:08:04 +00:00
print(args.unblock + ' does not look like an actor url')
2019-07-17 22:09:09 +00:00
sys.exit()
2021-12-28 16:56:57 +00:00
session = create_session(proxy_type)
2021-12-25 22:17:49 +00:00
person_cache = {}
2021-12-25 22:28:18 +00:00
cached_webfingers = {}
if not domain:
2021-12-26 14:08:58 +00:00
domain = get_config_param(base_dir, 'domain')
2021-12-25 23:03:28 +00:00
signing_priv_key_pem = None
2021-12-25 21:07:06 +00:00
if args.secure_mode:
2021-12-28 18:13:52 +00:00
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
2020-04-03 10:08:04 +00:00
print('Sending undo block of ' + args.unblock)
2019-07-17 22:09:09 +00:00
2021-12-29 21:55:09 +00:00
send_undo_block_via_server(base_dir, session, nickname, args.password,
domain, port,
http_prefix, args.unblock,
cached_webfingers, person_cache,
True, __version__, signing_priv_key_pem)
2019-07-17 22:09:09 +00:00
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
2019-07-14 19:57:05 +00:00
sys.exit()
2019-07-14 20:50:27 +00:00
if args.filterStr:
if not args.nickname:
print('Please specify a nickname')
sys.exit()
2021-12-29 21:55:09 +00:00
if add_filter(base_dir, args.nickname, domain, args.filterStr):
2020-04-03 10:08:04 +00:00
print('Filter added to ' + args.nickname + ': ' + args.filterStr)
2019-07-14 20:50:27 +00:00
sys.exit()
if args.unfilterStr:
if not args.nickname:
print('Please specify a nickname')
sys.exit()
2021-12-29 21:55:09 +00:00
if remove_filter(base_dir, args.nickname, domain, args.unfilterStr):
2020-04-03 10:08:04 +00:00
print('Filter removed from ' + args.nickname + ': ' + args.unfilterStr)
2019-07-14 20:50:27 +00:00
sys.exit()
2019-07-06 20:19:49 +00:00
if args.testdata:
2021-07-18 09:55:49 +00:00
args.language = 'en'
2021-05-09 19:29:53 +00:00
city = 'London, England'
2020-04-03 10:08:04 +00:00
nickname = 'testuser567'
password = 'boringpassword'
print('Generating some test data for user: ' + nickname)
2021-12-25 16:17:53 +00:00
if os.path.isdir(base_dir + '/tags'):
shutil.rmtree(base_dir + '/tags', ignore_errors=False, onerror=None)
if os.path.isdir(base_dir + '/accounts'):
shutil.rmtree(base_dir + '/accounts',
2021-10-29 18:48:15 +00:00
ignore_errors=False, onerror=None)
2021-12-25 16:17:53 +00:00
if os.path.isdir(base_dir + '/keys'):
shutil.rmtree(base_dir + '/keys', ignore_errors=False, onerror=None)
if os.path.isdir(base_dir + '/media'):
shutil.rmtree(base_dir + '/media', ignore_errors=False, onerror=None)
if os.path.isdir(base_dir + '/sharefiles'):
shutil.rmtree(base_dir + '/sharefiles',
ignore_errors=False, onerror=None)
if os.path.isdir(base_dir + '/wfendpoints'):
shutil.rmtree(base_dir + '/wfendpoints',
2021-10-29 18:48:15 +00:00
ignore_errors=False, onerror=None)
2020-04-03 10:08:04 +00:00
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'registrationsRemaining',
str(maxRegistrations))
2020-04-03 10:08:04 +00:00
2021-12-29 21:55:09 +00:00
create_person(base_dir, 'maxboardroom', domain, port, http_prefix,
True, False, password)
create_person(base_dir, 'ultrapancake', domain, port, http_prefix,
True, False, password)
create_person(base_dir, 'drokk', domain, port, http_prefix,
True, False, password)
create_person(base_dir, 'sausagedog', domain, port, http_prefix,
True, False, password)
create_person(base_dir, nickname, domain, port, http_prefix,
True, False, 'likewhateveryouwantscoob')
set_skill_level(base_dir, nickname, domain, 'testing', 60)
set_skill_level(base_dir, nickname, domain, 'typing', 50)
2021-12-28 22:22:09 +00:00
set_role(base_dir, nickname, domain, 'admin')
2021-12-29 21:55:09 +00:00
set_availability(base_dir, nickname, domain, 'busy')
add_share(base_dir,
http_prefix, nickname, domain, port,
"spanner",
"It's a spanner",
"img/shares1.png",
1, "tool",
"mechanical",
"City", "0", "GBP",
"2 months",
debug, city, args.language, {}, 'shares', args.low_bandwidth,
args.content_license_url)
add_share(base_dir,
http_prefix, nickname, domain, port,
"witch hat",
"Spooky",
"img/shares2.png",
1, "hat",
"clothing",
"City", "0", "GBP",
"3 months",
debug, city, args.language, {}, 'shares', args.low_bandwidth,
args.content_license_url)
delete_all_posts(base_dir, nickname, domain, 'inbox')
delete_all_posts(base_dir, nickname, domain, 'outbox')
2022-01-04 21:19:06 +00:00
test_followers_only = False
test_save_to_file = True
test_c2s = False
test_comments_enabled = True
test_attach_image_filename = None
test_media_type = None
test_image_description = None
test_city = 'London, England'
test_in_reply_to = None
test_in_reply_to_atom_uri = None
test_subject = None
test_schedule_post = False
test_event_date = None
test_event_time = None
test_location = None
test_is_article = False
conversation_id = None
2021-12-25 18:20:56 +00:00
low_bandwidth = False
languages_understood = [args.language]
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"like this is totally just a #test man",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
test_attach_image_filename,
test_media_type, test_image_description, test_city,
test_in_reply_to, test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"Zoiks!!!",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
test_attach_image_filename,
test_media_type, test_image_description, test_city,
test_in_reply_to, test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"Hey scoob we need like a hundred more #milkshakes",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
test_attach_image_filename,
test_media_type, test_image_description, test_city,
test_in_reply_to, test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"Getting kinda spooky around here",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
test_attach_image_filename,
test_media_type, test_image_description, test_city,
'someone', test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"And they would have gotten away with it too" +
"if it wasn't for those pesky hackers",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
2021-12-28 19:33:29 +00:00
'img/logo.png', 'image/png',
2022-01-04 21:19:06 +00:00
'Description of image', test_city,
test_in_reply_to, test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"man these centralized sites are like the worst!",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
test_attach_image_filename,
test_media_type, test_image_description, test_city,
test_in_reply_to, test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"another mystery solved #test",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
test_attach_image_filename,
test_media_type, test_image_description, test_city,
test_in_reply_to, test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-28 19:33:29 +00:00
create_public_post(base_dir, nickname, domain, port, http_prefix,
"let's go bowling",
2022-01-04 21:19:06 +00:00
test_followers_only,
test_save_to_file,
test_c2s,
test_comments_enabled,
test_attach_image_filename,
test_media_type, test_image_description, test_city,
test_in_reply_to, test_in_reply_to_atom_uri,
test_subject, test_schedule_post,
test_event_date, test_event_time, test_location,
test_is_article, args.language, conversation_id,
low_bandwidth, args.content_license_url,
languages_understood)
2021-12-26 10:00:46 +00:00
domain_full = domain + ':' + str(port)
2021-12-29 21:55:09 +00:00
clear_follows(base_dir, nickname, domain)
2021-12-27 17:08:19 +00:00
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'ultrapancake', domain_full,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'sausagedog', domain_full,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'drokk', domain_full,
federation_list, False, False)
2021-12-29 21:55:09 +00:00
add_follower_of_person(base_dir, nickname, domain, 'drokk', domain_full,
federation_list, False, False)
2021-12-29 22:45:26 +00:00
add_follower_of_person(base_dir, nickname, domain, 'maxboardroom',
domain_full, federation_list, False, False)
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'admin', nickname)
2019-09-30 10:15:20 +00:00
# set a lower bound to the maximum mentions
# so that it can't be accidentally set to zero and disable replies
2021-12-25 21:02:44 +00:00
if args.max_mentions < 4:
args.max_mentions = 4
2019-11-13 10:32:12 +00:00
2021-12-26 14:08:58 +00:00
registration = get_config_param(base_dir, 'registration')
2019-11-13 10:32:12 +00:00
if not registration:
2020-04-03 10:08:04 +00:00
registration = False
2021-12-26 14:08:58 +00:00
minimumvotes = get_config_param(base_dir, 'minvotes')
if minimumvotes:
args.minimumvotes = int(minimumvotes)
2021-12-25 17:13:38 +00:00
content_license_url = ''
if args.content_license_url:
content_license_url = args.content_license_url
2021-12-30 13:56:38 +00:00
set_config_param(base_dir, 'contentLicenseUrl', content_license_url)
2021-11-08 16:17:07 +00:00
else:
2021-12-30 13:56:38 +00:00
content_license_url = get_config_param(base_dir, 'contentLicenseUrl')
2021-11-08 16:17:07 +00:00
2021-12-26 14:08:58 +00:00
votingtime = get_config_param(base_dir, 'votingtime')
2020-10-10 13:52:50 +00:00
if votingtime:
args.votingtime = votingtime
2020-10-10 15:56:44 +00:00
# only show the date at the bottom of posts
2021-12-26 14:08:58 +00:00
dateonly = get_config_param(base_dir, 'dateonly')
if dateonly:
args.dateonly = dateonly
# set the maximum number of newswire posts per account or rss feed
2021-12-25 18:49:19 +00:00
max_newswire_postsPerSource = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxNewswirePostsPerSource')
2021-12-25 18:49:19 +00:00
if max_newswire_postsPerSource:
args.max_newswire_postsPerSource = int(max_newswire_postsPerSource)
# set the maximum number of newswire posts appearing in the right column
2021-12-25 18:49:19 +00:00
max_newswire_posts = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxNewswirePosts')
2021-12-25 18:49:19 +00:00
if max_newswire_posts:
args.max_newswire_posts = int(max_newswire_posts)
# set the maximum size of a newswire rss/atom feed in Kilobytes
2021-12-25 20:09:29 +00:00
max_newswire_feed_size_kb = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxNewswireFeedSizeKb')
2021-12-25 20:09:29 +00:00
if max_newswire_feed_size_kb:
args.max_newswire_feed_size_kb = int(max_newswire_feed_size_kb)
2020-10-19 16:33:58 +00:00
2021-12-25 19:42:14 +00:00
max_mirrored_articles = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxMirroredArticles')
2021-12-25 19:42:14 +00:00
if max_mirrored_articles is not None:
args.max_mirrored_articles = int(max_mirrored_articles)
2021-12-25 19:39:45 +00:00
max_news_posts = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxNewsPosts')
2021-12-25 19:39:45 +00:00
if max_news_posts is not None:
args.max_news_posts = int(max_news_posts)
2020-10-21 11:08:57 +00:00
2021-12-25 19:37:10 +00:00
max_followers = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxFollowers')
2021-12-25 19:37:10 +00:00
if max_followers is not None:
args.max_followers = int(max_followers)
2021-12-25 18:57:13 +00:00
max_feed_item_size_kb = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxFeedItemSizeKb')
2021-12-25 18:57:13 +00:00
if max_feed_item_size_kb is not None:
args.max_feed_item_size_kb = int(max_feed_item_size_kb)
2021-12-25 18:47:04 +00:00
dormant_months = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'dormantMonths')
2021-12-25 18:47:04 +00:00
if dormant_months is not None:
args.dormant_months = int(dormant_months)
2021-12-25 18:44:18 +00:00
send_threads_timeout_mins = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'sendThreadsTimeoutMins')
2021-12-25 18:44:18 +00:00
if send_threads_timeout_mins is not None:
args.send_threads_timeout_mins = int(send_threads_timeout_mins)
2021-12-25 18:23:12 +00:00
max_like_count = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'maxLikeCount')
2021-12-25 18:23:12 +00:00
if max_like_count is not None:
args.max_like_count = int(max_like_count)
2021-12-25 19:34:20 +00:00
show_publish_as_icon = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'showPublishAsIcon')
2021-12-25 19:34:20 +00:00
if show_publish_as_icon is not None:
args.show_publish_as_icon = bool(show_publish_as_icon)
2021-12-25 19:19:14 +00:00
icons_as_buttons = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'iconsAsButtons')
2021-12-25 19:19:14 +00:00
if icons_as_buttons is not None:
args.icons_as_buttons = bool(icons_as_buttons)
2020-10-25 20:38:01 +00:00
2021-12-25 19:09:03 +00:00
rss_icon_at_top = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'rssIconAtTop')
2021-12-25 19:09:03 +00:00
if rss_icon_at_top is not None:
args.rss_icon_at_top = bool(rss_icon_at_top)
2021-12-25 19:00:00 +00:00
publish_button_at_top = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'publishButtonAtTop')
2021-12-25 19:00:00 +00:00
if publish_button_at_top is not None:
args.publish_button_at_top = bool(publish_button_at_top)
2020-10-26 21:32:08 +00:00
2021-12-25 19:31:24 +00:00
full_width_tl_button_header = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'fullWidthTlButtonHeader')
2021-12-25 19:31:24 +00:00
if full_width_tl_button_header is not None:
args.full_width_tl_button_header = bool(full_width_tl_button_header)
2021-12-25 18:54:50 +00:00
allow_local_network_access = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'allowLocalNetworkAccess')
2021-12-25 18:54:50 +00:00
if allow_local_network_access is not None:
args.allow_local_network_access = bool(allow_local_network_access)
2020-11-20 11:49:11 +00:00
2021-12-25 18:40:32 +00:00
verify_all_signatures = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'verifyAllSignatures')
2021-12-25 18:40:32 +00:00
if verify_all_signatures is not None:
args.verify_all_signatures = bool(verify_all_signatures)
2022-01-26 22:13:23 +00:00
broch_mode = get_config_param(base_dir, 'brochMode')
2021-12-25 18:38:19 +00:00
if broch_mode is not None:
args.broch_mode = bool(broch_mode)
2021-02-15 22:06:53 +00:00
2022-01-26 22:13:23 +00:00
dyslexic_font = get_config_param(base_dir, 'dyslexicFont')
if dyslexic_font is not None:
args.dyslexic_font = bool(dyslexic_font)
2021-12-25 18:29:29 +00:00
log_login_failures = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'logLoginFailures')
2021-12-25 18:29:29 +00:00
if log_login_failures is not None:
args.log_login_failures = bool(log_login_failures)
2021-06-09 15:19:30 +00:00
2021-12-25 18:32:17 +00:00
show_node_info_accounts = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'showNodeInfoAccounts')
2021-12-25 18:32:17 +00:00
if show_node_info_accounts is not None:
args.show_node_info_accounts = bool(show_node_info_accounts)
2021-12-25 18:35:24 +00:00
show_node_info_version = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'showNodeInfoVersion')
2021-12-25 18:35:24 +00:00
if show_node_info_version is not None:
args.show_node_info_version = bool(show_node_info_version)
2021-12-25 18:20:56 +00:00
low_bandwidth = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'lowBandwidth')
2021-12-25 18:20:56 +00:00
if low_bandwidth is not None:
args.low_bandwidth = bool(low_bandwidth)
2021-08-13 17:31:07 +00:00
2021-12-25 18:27:11 +00:00
user_agents_blocked = []
2021-06-20 17:48:50 +00:00
if args.userAgentBlocks:
2022-01-04 21:19:06 +00:00
user_agents_blocked_str = args.userAgentBlocks
set_config_param(base_dir, 'userAgentsBlocked', user_agents_blocked_str)
2021-06-20 17:48:50 +00:00
else:
2022-01-04 21:19:06 +00:00
user_agents_blocked_str = \
2021-12-30 13:56:38 +00:00
get_config_param(base_dir, 'userAgentsBlocked')
2022-01-04 21:19:06 +00:00
if user_agents_blocked_str:
agent_blocks_list = user_agents_blocked_str.split(',')
2022-03-06 12:31:58 +00:00
for user_agents_blocked_str2 in agent_blocks_list:
user_agents_blocked.append(user_agents_blocked_str2.strip())
crawlers_allowed = []
if args.crawlersAllowed:
crawlers_allowed_str = args.crawlersAllowed
set_config_param(base_dir, 'crawlersAllowed', crawlers_allowed_str)
else:
crawlers_allowed_str = \
get_config_param(base_dir, 'crawlersAllowed')
if crawlers_allowed_str:
crawlers_allowed_list = crawlers_allowed_str.split(',')
for crawlers_allowed_str2 in crawlers_allowed_list:
crawlers_allowed.append(crawlers_allowed_str2.strip())
2021-06-20 13:25:18 +00:00
2021-12-25 18:12:13 +00:00
lists_enabled = ''
if args.lists_enabled:
lists_enabled = args.lists_enabled
2021-12-30 13:56:38 +00:00
set_config_param(base_dir, 'listsEnabled', lists_enabled)
2021-10-21 14:06:25 +00:00
else:
2021-12-30 13:56:38 +00:00
lists_enabled = get_config_param(base_dir, 'listsEnabled')
2021-10-21 14:06:25 +00:00
2021-05-09 19:11:05 +00:00
city = \
2021-12-26 14:08:58 +00:00
get_config_param(base_dir, 'city')
2021-05-09 19:11:05 +00:00
if city is not None:
args.city = city
2022-01-04 21:19:06 +00:00
yt_domain = get_config_param(base_dir, 'youtubedomain')
if yt_domain:
if '://' in yt_domain:
yt_domain = yt_domain.split('://')[1]
if '/' in yt_domain:
yt_domain = yt_domain.split('/')[0]
if '.' in yt_domain:
args.yt_replace_domain = yt_domain
twitter_domain = get_config_param(base_dir, 'twitterdomain')
if twitter_domain:
if '://' in twitter_domain:
twitter_domain = twitter_domain.split('://')[1]
if '/' in twitter_domain:
twitter_domain = twitter_domain.split('/')[0]
if '.' in twitter_domain:
args.twitter_replacement_domain = twitter_domain
2021-09-18 17:08:14 +00:00
2021-12-29 21:55:09 +00:00
if set_theme(base_dir, theme_name, domain,
2022-01-26 23:17:53 +00:00
args.allow_local_network_access, args.language,
args.dyslexic_font):
2021-12-25 23:35:50 +00:00
print('Theme set to ' + theme_name)
2020-04-03 10:08:04 +00:00
2021-06-13 10:48:52 +00:00
# whether new registrations are open or closed
if args.registration:
if args.registration.lower() == 'open':
2021-12-26 14:08:58 +00:00
registration = get_config_param(base_dir, 'registration')
2021-06-13 10:48:52 +00:00
if not registration:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'registrationsRemaining',
str(maxRegistrations))
2021-06-13 10:48:52 +00:00
else:
if registration != 'open':
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'registrationsRemaining',
str(maxRegistrations))
set_config_param(base_dir, 'registration', 'open')
2021-06-13 10:48:52 +00:00
print('New registrations open')
else:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'registration', 'closed')
2021-06-13 10:48:52 +00:00
print('New registrations closed')
2022-01-04 21:19:06 +00:00
default_currency = get_config_param(base_dir, 'defaultCurrency')
if not default_currency:
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'defaultCurrency', 'EUR')
2021-08-07 18:07:08 +00:00
if args.defaultCurrency:
if args.defaultCurrency == args.defaultCurrency.upper():
2021-12-27 20:38:02 +00:00
set_config_param(base_dir, 'defaultCurrency', args.defaultCurrency)
2021-08-07 18:07:08 +00:00
print('Default currency set to ' + args.defaultCurrency)
if __name__ == "__main__":
2022-03-06 12:31:58 +00:00
run_daemon(crawlers_allowed,
args.dyslexic_font,
2022-01-26 22:13:23 +00:00
content_license_url,
2021-12-29 21:55:09 +00:00
lists_enabled,
args.default_reply_interval_hrs,
args.low_bandwidth, args.max_like_count,
shared_items_federated_domains,
user_agents_blocked,
args.log_login_failures,
args.city,
args.show_node_info_accounts,
args.show_node_info_version,
args.broch_mode,
args.verify_all_signatures,
args.send_threads_timeout_mins,
args.dormant_months,
args.max_newswire_posts,
args.allow_local_network_access,
args.max_feed_item_size_kb,
args.publish_button_at_top,
args.rss_icon_at_top,
args.icons_as_buttons,
args.full_width_tl_button_header,
args.show_publish_as_icon,
args.max_followers,
args.max_news_posts,
args.max_mirrored_articles,
args.max_newswire_feed_size_kb,
args.max_newswire_postsPerSource,
args.dateonly,
args.votingtime,
args.positivevoting,
args.minimumvotes,
args.newsinstance,
args.blogsinstance, args.mediainstance,
args.max_recent_posts,
not args.nosharedinbox,
registration, args.language, __version__,
instance_id, args.client, base_dir,
domain, onion_domain, i2p_domain,
args.yt_replace_domain,
args.twitter_replacement_domain,
port, proxy_port, http_prefix,
federation_list, args.max_mentions,
args.max_emoji, args.secure_mode,
proxy_type, args.max_replies,
args.domain_max_posts_per_day,
args.account_max_posts_per_day,
args.allowdeletion, debug, False,
args.instance_only_skills_search, [],
not args.noapproval)