-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
daemon_post_person_options.py
1714 lines (1603 loc) · 71.2 KB
/
daemon_post_person_options.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
__filename__ = "daemon_post_person_options.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.5.0"
__maintainer__ = "Bob Mottram"
__email__ = "[email protected]"
__status__ = "Production"
__module_group__ = "Core POST"
import os
import errno
import urllib.parse
from socket import error as SocketError
from utils import get_nickname_from_actor
from httpcodes import write2
from httpcodes import http_404
from httpheaders import login_headers
from httpheaders import redirect_headers
from httpheaders import set_headers
from utils import refresh_newswire
from utils import acct_dir
from utils import get_config_param
from utils import get_domain_from_actor
from utils import get_full_domain
from utils import remove_eol
from session import establish_session
from webapp_profile import html_profile_after_search
from petnames import set_pet_name
from person import person_snooze
from person import person_unsnooze
from person import set_person_notes
from followingCalendar import add_person_to_calendar
from followingCalendar import remove_person_from_calendar
from webapp_person_options import person_minimize_images
from webapp_person_options import person_undo_minimize_images
from webapp_confirm import html_confirm_block
from webapp_confirm import html_confirm_unblock
from webapp_confirm import html_confirm_follow
from webapp_confirm import html_confirm_unfollow
from webapp_create_post import html_new_post
from webapp_moderation import html_account_info
from languages import get_understood_languages
from blocking import allowed_announce_add
from blocking import allowed_announce_remove
from blocking import blocked_quote_toots_add
from blocking import blocked_quote_toots_remove
from notifyOnPost import add_notify_on_post
from notifyOnPost import remove_notify_on_post
from posts import is_moderator
def _person_options_page_number(options_confirm_params: str) -> int:
"""Get the page number
"""
page_number = 1
if 'pageNumber=' in options_confirm_params:
page_number_str = options_confirm_params.split('pageNumber=')[1]
if '&' in page_number_str:
page_number_str = page_number_str.split('&')[0]
if len(page_number_str) < 5:
if page_number_str.isdigit():
page_number = int(page_number_str)
return page_number
def _person_options_actor(options_confirm_params: str) -> str:
"""Get the actor
"""
options_actor = options_confirm_params.split('actor=')[1]
if '&' in options_actor:
options_actor = options_actor.split('&')[0]
return options_actor
def _person_options_moved_to(options_confirm_params: str) -> str:
"""actor for movedTo
"""
options_actor_moved = None
if 'movedToActor=' in options_confirm_params:
options_actor_moved = \
options_confirm_params.split('movedToActor=')[1]
if '&' in options_actor_moved:
options_actor_moved = options_actor_moved.split('&')[0]
return options_actor_moved
def _person_options_avatar_url(options_confirm_params: str) -> str:
"""url of the avatar
"""
options_avatar_url = options_confirm_params.split('avatarUrl=')[1]
if '&' in options_avatar_url:
options_avatar_url = options_avatar_url.split('&')[0]
return options_avatar_url
def _person_options_post_url(options_confirm_params: str) -> str:
"""link to a post, which can then be included in reports
"""
post_url = None
if 'postUrl' in options_confirm_params:
post_url = options_confirm_params.split('postUrl=')[1]
if '&' in post_url:
post_url = post_url.split('&')[0]
return post_url
def _person_options_petname(options_confirm_params: str) -> str:
"""petname for this person
"""
petname = None
if 'optionpetname' in options_confirm_params:
petname = options_confirm_params.split('optionpetname=')[1]
if '&' in petname:
petname = petname.split('&')[0]
# Limit the length of the petname
if len(petname) > 20 or \
' ' in petname or '/' in petname or \
'?' in petname or '#' in petname:
petname = None
return petname
def _person_option_receive_petname(self, options_confirm_params: str,
petname: str, debug: bool,
options_nickname: str,
options_domain_full: str,
base_dir: str,
chooser_nickname: str,
domain: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""person options screen, petname submit button
See html_person_options
"""
if '&submitPetname=' in options_confirm_params and petname:
if debug:
print('Change petname to ' + petname)
handle = options_nickname + '@' + options_domain_full
set_pet_name(base_dir,
chooser_nickname,
domain,
handle, petname)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_notes(options_confirm_params: str) -> str:
"""notes about this person
"""
person_notes = None
if 'optionnotes' in options_confirm_params:
person_notes = options_confirm_params.split('optionnotes=')[1]
if '&' in person_notes:
person_notes = person_notes.split('&')[0]
person_notes = urllib.parse.unquote_plus(person_notes.strip())
# Limit the length of the notes
if len(person_notes) > 64000:
person_notes = None
return person_notes
def _person_options_receive_notes(self, options_confirm_params: str,
debug: bool,
options_nickname: str,
options_domain_full: str,
person_notes: str,
base_dir: str,
chooser_nickname: str,
domain: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, person notes submit button
See html_person_options
"""
if '&submitPersonNotes=' in options_confirm_params:
if debug:
print('Change person notes')
handle = options_nickname + '@' + options_domain_full
if not person_notes:
person_notes = ''
set_person_notes(base_dir,
chooser_nickname,
domain,
handle, person_notes)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_view(self, options_confirm_params: str,
debug: bool,
options_actor: str,
key_shortcuts: {},
chooser_nickname: str,
account_timezone: {},
proxy_type: str,
bold_reading_nicknames: {},
authorized: bool,
recent_posts_cache: {},
max_recent_posts: int,
translate: {},
base_dir: str,
users_path: str,
http_prefix: str,
domain: str,
port: int,
cached_webfingers: {},
person_cache: {},
project_version: str,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
default_timeline: str,
peertube_instances: [],
allow_local_network_access: bool,
theme_name: str,
system_language: str,
max_like_count: int,
signing_priv_key_pem: str,
cw_lists: {},
lists_enabled: {},
onion_domain: str,
i2p_domain: str,
dogwhistles: {},
min_images_for_accounts: {},
buy_sites: [],
max_shares_on_profile: int,
no_of_books: int,
auto_cw_cache: {},
cookie: str,
calling_domain: str,
curr_session, access_keys: {},
mitm_servers: [],
ua_str: str) -> bool:
"""Person options screen, view button
See html_person_options
"""
if '&submitView=' in options_confirm_params:
if debug:
print('Viewing ' + options_actor)
if key_shortcuts.get(chooser_nickname):
access_keys = key_shortcuts[chooser_nickname]
timezone = None
if account_timezone.get(chooser_nickname):
timezone = account_timezone.get(chooser_nickname)
profile_handle = remove_eol(options_actor).strip()
# establish the session
curr_proxy_type = proxy_type
if '.onion/' in profile_handle or \
profile_handle.endswith('.onion'):
curr_proxy_type = 'tor'
curr_session = self.server.session_onion
elif ('.i2p/' in profile_handle or
profile_handle.endswith('.i2p')):
curr_proxy_type = 'i2p'
curr_session = self.server.session_i2p
curr_session = \
establish_session("handle search",
curr_session,
curr_proxy_type,
self.server)
if not curr_session:
self.server.postreq_busy = False
return True
bold_reading = False
if bold_reading_nicknames.get(chooser_nickname):
bold_reading = True
profile_str = \
html_profile_after_search(authorized,
recent_posts_cache,
max_recent_posts,
translate,
base_dir,
users_path,
http_prefix,
chooser_nickname,
domain,
port,
profile_handle,
curr_session,
cached_webfingers,
person_cache,
debug,
project_version,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
default_timeline,
peertube_instances,
allow_local_network_access,
theme_name,
access_keys,
system_language,
max_like_count,
signing_priv_key_pem,
cw_lists,
lists_enabled,
timezone,
onion_domain,
i2p_domain,
bold_reading,
dogwhistles,
min_images_for_accounts,
buy_sites,
max_shares_on_profile,
no_of_books,
auto_cw_cache,
mitm_servers,
ua_str)
if profile_str:
msg = profile_str.encode('utf-8')
msglen = len(msg)
login_headers(self, 'text/html',
msglen, calling_domain)
write2(self, msg)
self.server.postreq_busy = False
return True
redirect_headers(self, options_actor,
cookie, calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_on_calendar(self, options_confirm_params: str,
base_dir: str,
chooser_nickname: str,
domain: str,
options_nickname: str,
options_domain_full: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, on calendar checkbox
See html_person_options
"""
if '&submitOnCalendar=' in options_confirm_params:
on_calendar = None
if 'onCalendar=' in options_confirm_params:
on_calendar = options_confirm_params.split('onCalendar=')[1]
if '&' in on_calendar:
on_calendar = on_calendar.split('&')[0]
if on_calendar == 'on':
add_person_to_calendar(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
else:
remove_person_from_calendar(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_min_images(self, options_confirm_params: str,
base_dir: str,
chooser_nickname: str,
domain: str,
options_nickname: str,
options_domain_full: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, minimize images checkbox
See html_person_options
"""
if '&submitMinimizeImages=' in options_confirm_params:
minimize_images = None
if 'minimizeImages=' in options_confirm_params:
minimize_images = \
options_confirm_params.split('minimizeImages=')[1]
if '&' in minimize_images:
minimize_images = minimize_images.split('&')[0]
if minimize_images == 'on':
person_minimize_images(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
else:
person_undo_minimize_images(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_allow_announce(self, options_confirm_params: str,
base_dir: str,
chooser_nickname: str,
domain: str,
options_nickname: str,
options_domain_full: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, allow announces checkbox
See html_person_options
"""
if '&submitAllowAnnounce=' in options_confirm_params:
allow_announce = None
if 'allowAnnounce=' in options_confirm_params:
allow_announce = \
options_confirm_params.split('allowAnnounce=')[1]
if '&' in allow_announce:
allow_announce = allow_announce.split('&')[0]
if allow_announce == 'on':
allowed_announce_add(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
else:
allowed_announce_remove(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_allow_quotes(self, options_confirm_params: str,
base_dir: str,
chooser_nickname: str,
domain: str,
options_nickname: str,
options_domain_full: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, allow quote toots checkbox
See html_person_options
"""
if '&submitAllowQuotes=' in options_confirm_params:
allow_quote_toots = None
if 'allowQuotes=' in options_confirm_params:
allow_quote_toots = \
options_confirm_params.split('allowQuotes=')[1]
if '&' in allow_quote_toots:
allow_quote_toots = allow_quote_toots.split('&')[0]
if allow_quote_toots != 'on':
blocked_quote_toots_add(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
else:
blocked_quote_toots_remove(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_notify(self, options_confirm_params: str,
base_dir: str,
chooser_nickname: str,
domain: str,
options_nickname: str,
options_domain_full: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, on notify checkbox
See html_person_options
"""
if '&submitNotifyOnPost=' in options_confirm_params:
notify = None
if 'notifyOnPost=' in options_confirm_params:
notify = options_confirm_params.split('notifyOnPost=')[1]
if '&' in notify:
notify = notify.split('&')[0]
if notify == 'on':
add_notify_on_post(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
else:
remove_notify_on_post(base_dir,
chooser_nickname,
domain,
options_nickname,
options_domain_full)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_post_to_news(self, options_confirm_params: str,
chooser_nickname: str,
base_dir: str,
options_nickname: str,
options_domain: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, permission to post to newswire
See html_person_options
"""
if '&submitPostToNews=' in options_confirm_params:
admin_nickname = get_config_param(base_dir, 'admin')
if (chooser_nickname != options_nickname and
(chooser_nickname == admin_nickname or
(is_moderator(base_dir, chooser_nickname) and
not is_moderator(base_dir, options_nickname)))):
posts_to_news = None
if 'postsToNews=' in options_confirm_params:
posts_to_news = \
options_confirm_params.split('postsToNews=')[1]
if '&' in posts_to_news:
posts_to_news = posts_to_news.split('&')[0]
account_dir = acct_dir(base_dir,
options_nickname, options_domain)
newswire_blocked_filename = account_dir + '/.nonewswire'
if posts_to_news == 'on':
if os.path.isfile(newswire_blocked_filename):
try:
os.remove(newswire_blocked_filename)
except OSError:
print('EX: _person_options unable to delete ' +
newswire_blocked_filename)
refresh_newswire(base_dir)
else:
if os.path.isdir(account_dir):
nw_filename = newswire_blocked_filename
nw_written = False
try:
with open(nw_filename, 'w+',
encoding='utf-8') as fp_no:
fp_no.write('\n')
nw_written = True
except OSError as ex:
print('EX: _person_options_post_to_news unable ' +
'to write ' + nw_filename + ' ' + str(ex))
if nw_written:
refresh_newswire(base_dir)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_post_to_features(self, options_confirm_params: str,
chooser_nickname: str,
options_nickname: str,
base_dir: str,
options_domain: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, permission to post to featured articles
See html_person_options
"""
if '&submitPostToFeatures=' in options_confirm_params:
admin_nickname = get_config_param(base_dir, 'admin')
if (chooser_nickname != options_nickname and
(chooser_nickname == admin_nickname or
(is_moderator(base_dir, chooser_nickname) and
not is_moderator(base_dir, options_nickname)))):
posts_to_features = None
if 'postsToFeatures=' in options_confirm_params:
posts_to_features = \
options_confirm_params.split('postsToFeatures=')[1]
if '&' in posts_to_features:
posts_to_features = posts_to_features.split('&')[0]
account_dir = acct_dir(base_dir,
options_nickname, options_domain)
features_blocked_filename = account_dir + '/.nofeatures'
if posts_to_features == 'on':
if os.path.isfile(features_blocked_filename):
try:
os.remove(features_blocked_filename)
except OSError:
print('EX: _person_options unable to delete ' +
features_blocked_filename)
refresh_newswire(base_dir)
else:
if os.path.isdir(account_dir):
feat_filename = features_blocked_filename
feat_written = False
try:
with open(feat_filename, 'w+',
encoding='utf-8') as fp_no:
fp_no.write('\n')
feat_written = True
except OSError as ex:
print('EX: _person_options_post_to_features ' +
'unable to write ' + feat_filename +
' ' + str(ex))
if feat_written:
refresh_newswire(base_dir)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_mod_news(self, options_confirm_params: str,
base_dir: str,
chooser_nickname: str,
options_nickname: str,
options_domain: str,
users_path: str,
default_timeline: str,
page_number: int,
cookie: str,
calling_domain: str) -> bool:
"""Person options screen, permission to post to newswire
See html_person_options
"""
if '&submitModNewsPosts=' in options_confirm_params:
admin_nickname = get_config_param(base_dir, 'admin')
if (chooser_nickname != options_nickname and
(chooser_nickname == admin_nickname or
(is_moderator(base_dir, chooser_nickname) and
not is_moderator(base_dir, options_nickname)))):
mod_posts_to_news = None
if 'modNewsPosts=' in options_confirm_params:
mod_posts_to_news = \
options_confirm_params.split('modNewsPosts=')[1]
if '&' in mod_posts_to_news:
mod_posts_to_news = mod_posts_to_news.split('&')[0]
account_dir = acct_dir(base_dir,
options_nickname, options_domain)
newswire_mod_filename = account_dir + '/.newswiremoderated'
if mod_posts_to_news != 'on':
if os.path.isfile(newswire_mod_filename):
try:
os.remove(newswire_mod_filename)
except OSError:
print('EX: _person_options unable to delete ' +
newswire_mod_filename)
else:
if os.path.isdir(account_dir):
nw_filename = newswire_mod_filename
try:
with open(nw_filename, 'w+',
encoding='utf-8') as fp_mod:
fp_mod.write('\n')
except OSError:
print('EX: _person_options_mod_news ' +
'unable to write ' + nw_filename)
users_path_str = \
users_path + '/' + default_timeline + \
'?page=' + str(page_number)
redirect_headers(self, users_path_str, cookie,
calling_domain, 303)
self.server.postreq_busy = False
return True
return False
def _person_options_block(self, options_confirm_params: str,
debug: bool,
options_actor: str,
translate: {},
base_dir: str,
users_path: str,
options_avatar_url: str,
cookie: str, calling_domain: str) -> bool:
"""Person options screen, block button
See html_person_options
"""
if '&submitBlock=' in options_confirm_params:
if debug:
print('Blocking ' + options_actor)
msg = \
html_confirm_block(translate,
base_dir,
users_path,
options_actor,
options_avatar_url).encode('utf-8')
msglen = len(msg)
set_headers(self, 'text/html', msglen,
cookie, calling_domain, False)
write2(self, msg)
self.server.postreq_busy = False
return True
return False
def _person_options_unblock(self, options_confirm_params: str,
debug: bool,
options_actor: str,
translate: {},
base_dir: str,
users_path: str,
options_avatar_url: str,
cookie: str, calling_domain: str) -> bool:
"""Person options screen, unblock button
See html_person_options
"""
if '&submitUnblock=' in options_confirm_params:
if debug:
print('Unblocking ' + options_actor)
msg = \
html_confirm_unblock(translate,
base_dir,
users_path,
options_actor,
options_avatar_url).encode('utf-8')
msglen = len(msg)
set_headers(self, 'text/html', msglen,
cookie, calling_domain, False)
write2(self, msg)
self.server.postreq_busy = False
return True
return False
def _person_options_follow(self, options_confirm_params: str,
debug: bool, options_actor: str,
translate: {},
base_dir: str,
users_path: str,
options_avatar_url: str,
chooser_nickname: str,
domain: str,
cookie: str, calling_domain: str) -> bool:
"""Person options screen, follow button
See html_person_options followStr
"""
if '&submitFollow=' in options_confirm_params or \
'&submitJoin=' in options_confirm_params:
if debug:
print('Following ' + options_actor)
msg = \
html_confirm_follow(translate,
base_dir,
users_path,
options_actor,
options_avatar_url,
chooser_nickname,
domain).encode('utf-8')
msglen = len(msg)
set_headers(self, 'text/html', msglen,
cookie, calling_domain, False)
write2(self, msg)
self.server.postreq_busy = False
return True
return False
def _person_options_move(self, options_confirm_params: str,
options_actor_moved: str,
debug: bool,
translate: {},
base_dir: str,
users_path: str,
options_avatar_url: str,
chooser_nickname: str,
domain: str,
cookie: str, calling_domain: str) -> bool:
"""Person options screen, move button
See html_person_options followStr
"""
if '&submitMove=' in options_confirm_params and options_actor_moved:
if debug:
print('Moving ' + options_actor_moved)
msg = \
html_confirm_follow(translate,
base_dir,
users_path,
options_actor_moved,
options_avatar_url,
chooser_nickname,
domain).encode('utf-8')
if msg:
msglen = len(msg)
set_headers(self, 'text/html', msglen,
cookie, calling_domain, False)
write2(self, msg)
self.server.postreq_busy = False
return True
return False
def _person_options_unfollow(self, options_confirm_params: str,
options_actor: str,
translate: {},
base_dir: str,
users_path: str,
options_avatar_url: str,
cookie: str, calling_domain: str) -> bool:
"""Person options screen, unfollow button
See html_person_options followStr
"""
if '&submitUnfollow=' in options_confirm_params or \
'&submitLeave=' in options_confirm_params:
print('Unfollowing ' + options_actor)
msg = \
html_confirm_unfollow(translate,
base_dir,
users_path,
options_actor,
options_avatar_url).encode('utf-8')
msglen = len(msg)
set_headers(self, 'text/html', msglen,
cookie, calling_domain, False)
write2(self, msg)
self.server.postreq_busy = False
return True
return False
def _person_options_dm(self, options_confirm_params: str,
debug: bool, options_actor: str,
path: str, key_shortcuts: {},
base_dir: str, bold_reading_nicknames: {},
chooser_nickname: str, http_prefix: str,
domain_full: str, person_cache: {},
system_language: str,
default_post_language: {},
translate: {}, page_number: int,
domain: str, default_timeline: str,
newswire: str, theme_name: str,
recent_posts_cache: {},
max_recent_posts: int,
curr_session,
cached_webfingers: {},
port: int, project_version: str,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
peertube_instances: [],
allow_local_network_access: bool,
max_like_count: int,
signing_priv_key_pem: str,
cw_lists: {},
lists_enabled: {},
dogwhistles: {},
min_images_for_accounts: {},
buy_sites: [],
auto_cw_cache: {},
cookie: str, calling_domain: str,
access_keys: {},
mitm_servers: []) -> bool:
"""Person options screen, DM button
See html_person_options
"""
if '&submitDM=' in options_confirm_params:
if debug:
print('Sending DM to ' + options_actor)
report_path = path.replace('/personoptions', '') + '/newdm'
if '/users/' in path:
nickname = path.split('/users/')[1]
if '/' in nickname:
nickname = nickname.split('/')[0]
if key_shortcuts.get(nickname):
access_keys = key_shortcuts[nickname]
custom_submit_text = get_config_param(base_dir, 'customSubmitText')
conversation_id = None
convthread_id = None
reply_is_chat = False
bold_reading = False
if bold_reading_nicknames.get(chooser_nickname):
bold_reading = True
languages_understood = \
get_understood_languages(base_dir,
http_prefix,
chooser_nickname,
domain_full,
person_cache)
default_post_language2 = system_language
if default_post_language.get(nickname):
default_post_language2 = default_post_language[nickname]
default_buy_site = ''
searchable_by_default = 'yourself'
msg = \
html_new_post({}, False, translate,
base_dir,
http_prefix,
report_path, None,
[options_actor], None, None,
page_number, '',
chooser_nickname,
domain,
domain_full,
default_timeline,
newswire,
theme_name,
True, access_keys,
custom_submit_text,
conversation_id, convthread_id,
recent_posts_cache,
max_recent_posts,
curr_session,
cached_webfingers,
person_cache,
port,
None,
project_version,
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
peertube_instances,
allow_local_network_access,
system_language,
languages_understood,
max_like_count,
signing_priv_key_pem,
cw_lists,
lists_enabled,
default_timeline,
reply_is_chat,
bold_reading,
dogwhistles,
min_images_for_accounts,
None, None, default_post_language2,
buy_sites,