Next huge chunk of refactoring completed.
This commit is contained in:
+97
-54
@@ -252,7 +252,7 @@ EOF
|
|||||||
getuliurl getufliurl dmsenturl reblogurl boostsbyurl dmidurl
|
getuliurl getufliurl dmsenturl reblogurl boostsbyurl dmidurl
|
||||||
statusliurl followliurl leaveliurl followersurl
|
statusliurl followliurl leaveliurl followersurl
|
||||||
oauthurl oauthauthurl oauthaccurl oauthbase wtrendurl
|
oauthurl oauthauthurl oauthaccurl oauthbase wtrendurl
|
||||||
atrendurl frupdurl lookupidurl boostsofmeurl
|
atrendurl lookupidurl
|
||||||
); %opts_secret = map { $_ => 1} qw(
|
); %opts_secret = map { $_ => 1} qw(
|
||||||
superverbose ttytteristas
|
superverbose ttytteristas
|
||||||
); %opts_comma_delimit = map { $_ => 1 } qw(
|
); %opts_comma_delimit = map { $_ => 1 } qw(
|
||||||
@@ -278,7 +278,7 @@ EOF
|
|||||||
getuliurl getufliurl dmsenturl reblogurl boostsbyurl wtrendurl
|
getuliurl getufliurl dmsenturl reblogurl boostsbyurl wtrendurl
|
||||||
statusliurl followliurl leaveliurl dmidurl nostreamreplies
|
statusliurl followliurl leaveliurl dmidurl nostreamreplies
|
||||||
frupdurl filterusers filterats filterrts filterflags
|
frupdurl filterusers filterats filterrts filterflags
|
||||||
filteratonly nofilter boostsofmeurl
|
filteratonly nofilter
|
||||||
); %opts_others = map { $_ => 1 } qw(
|
); %opts_others = map { $_ => 1 } qw(
|
||||||
lynx curl seven silent maxhist noansi hold status
|
lynx curl seven silent maxhist noansi hold status
|
||||||
daemon timestamp twarg user anonymous script readline
|
daemon timestamp twarg user anonymous script readline
|
||||||
@@ -1025,19 +1025,20 @@ $idurl ||= "${apibase}/statuses/%I";
|
|||||||
$delurl ||= "${apibase}/statuses/%I";
|
$delurl ||= "${apibase}/statuses/%I";
|
||||||
|
|
||||||
$reblogurl ||= "${apibase}/statuses/%I/reblog";
|
$reblogurl ||= "${apibase}/statuses/%I/reblog";
|
||||||
$boostsbyurl ||= "${apibase}/statuses/reposts/%I.json";
|
# Twitter endpoints removed - not available in fediverse
|
||||||
$boostsofmeurl ||= "${apibase}/statuses/reposts_of_me.json";
|
# $boostsbyurl: Use /api/v1/statuses/%I/reblogged_by instead
|
||||||
|
# $boostsofmeurl: No direct equivalent in fediverse (privacy feature)
|
||||||
|
|
||||||
$wurl ||= "${apibase}/accounts/%I";
|
$wurl ||= "${apibase}/accounts/%I";
|
||||||
|
|
||||||
$frurl ||= "${apibase}/friendships/show.json";
|
# Twitter friendships API removed - use /api/v1/accounts/relationships instead
|
||||||
$followurl ||= "${apibase}/accounts/%I/follow";
|
$followurl ||= "${apibase}/accounts/%I/follow";
|
||||||
$leaveurl ||= "${apibase}/accounts/%I/unfollow";
|
$leaveurl ||= "${apibase}/accounts/%I/unfollow";
|
||||||
$blockurl ||= "${apibase}/accounts/%I/block";
|
$blockurl ||= "${apibase}/accounts/%I/block";
|
||||||
$blockdelurl ||= "${apibase}/accounts/%I/unblock";
|
$blockdelurl ||= "${apibase}/accounts/%I/unblock";
|
||||||
$friendsurl ||= "${apibase}/accounts/%I/following";
|
$friendsurl ||= "${apibase}/accounts/%I/following";
|
||||||
$followersurl ||= "${apibase}/accounts/%I/followers";
|
$followersurl ||= "${apibase}/accounts/%I/followers";
|
||||||
$frupdurl ||= "${apibase}/friendships/update.json";
|
# Twitter friendships/update removed - fediverse uses individual follow/unfollow endpoints
|
||||||
$lookupidurl ||= "${apibase}/accounts/lookup";
|
$lookupidurl ||= "${apibase}/accounts/lookup";
|
||||||
|
|
||||||
$rlurl ||= "${apibase}/instance"; # Mastodon instance info instead of rate limits
|
$rlurl ||= "${apibase}/instance"; # Mastodon instance info instead of rate limits
|
||||||
@@ -1052,19 +1053,16 @@ $favsurl ||= "${apibase}/favourites";
|
|||||||
$favurl ||= "${apibase}/statuses/%I/favourite";
|
$favurl ||= "${apibase}/statuses/%I/favourite";
|
||||||
$favdelurl ||= "${apibase}/statuses/%I/unfavourite";
|
$favdelurl ||= "${apibase}/statuses/%I/unfavourite";
|
||||||
|
|
||||||
$getlisurl ||= "${apibase}/lists/list.json";
|
# Fediverse list APIs (simplified compared to Twitter)
|
||||||
$creliurl ||= "${apibase}/lists/create.json";
|
$getlisurl ||= "${apibase}/lists"; # GET lists
|
||||||
$delliurl ||= "${apibase}/lists/destroy.json";
|
$creliurl ||= "${apibase}/lists"; # POST create list
|
||||||
$modifyliurl ||= "${apibase}/lists/update.json";
|
$delliurl ||= "${apibase}/lists/%I"; # DELETE list
|
||||||
$deluliurl ||= "${apibase}/lists/members/destroy_all.json";
|
$modifyliurl ||= "${apibase}/lists/%I"; # PUT update list
|
||||||
$adduliurl ||= "${apibase}/lists/members/create_all.json";
|
$getliurl ||= "${apibase}/lists/%I/accounts"; # GET list members
|
||||||
$getuliurl ||= "${apibase}/lists/memberships.json";
|
$adduliurl ||= "${apibase}/lists/%I/accounts"; # POST add members
|
||||||
$getufliurl ||= "${apibase}/lists/subscriptions.json";
|
$deluliurl ||= "${apibase}/lists/%I/accounts"; # DELETE remove members
|
||||||
$delfliurl ||= "${apibase}/lists/subscribers/destroy.json";
|
$statusliurl ||= "${apibase}/lists/%I"; # GET list timeline
|
||||||
$crefliurl ||= "${apibase}/lists/subscribers/create.json";
|
# Note: Fediverse doesn't have list subscriptions/followers like Twitter
|
||||||
$getfliurl ||= "${apibase}/lists/subscribers.json";
|
|
||||||
$getliurl ||= "${apibase}/lists/members.json";
|
|
||||||
$statusliurl ||= "${apibase}/lists/statuses.json";
|
|
||||||
|
|
||||||
$streamurl ||= "${http_proto}://${fediverseserver}/api/v1/streaming";
|
$streamurl ||= "${http_proto}://${fediverseserver}/api/v1/streaming";
|
||||||
$dostream ||= 0;
|
$dostream ||= 0;
|
||||||
@@ -2619,13 +2617,16 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n";
|
|||||||
}
|
}
|
||||||
$uname ||= $whoami;
|
$uname ||= $whoami;
|
||||||
|
|
||||||
# check the list validity
|
# In fediverse, can only access your own lists (privacy feature)
|
||||||
my $my_json_ref = &grabjson(
|
if ($uname ne $whoami) {
|
||||||
"${statusliurl}?owner_screen_name=${uname}&slug=${lname}",
|
print $stdout "-- Sorry, fediverse only allows access to your own lists (privacy feature)\n";
|
||||||
0, 0, 0, undef, 1);
|
return 0;
|
||||||
if (!$my_json_ref || ref($my_json_ref) ne 'ARRAY') {
|
}
|
||||||
print $stdout
|
|
||||||
"*** list $uname/$lname seems bogus; not added\n";
|
# Look up list ID by title
|
||||||
|
my $list_id = &lookup_list_id($lname);
|
||||||
|
if (!$list_id) {
|
||||||
|
print $stdout "*** list '$lname' not found; use /lists to see available lists\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3086,12 +3087,30 @@ EOF
|
|||||||
$mode = ($mode eq 'frs' || $mode eq 'friends')
|
$mode = ($mode eq 'frs' || $mode eq 'friends')
|
||||||
? $friendsurl : $followersurl;
|
? $friendsurl : $followersurl;
|
||||||
} else {
|
} else {
|
||||||
$what = ($mode eq 'frs' || $mode eq 'friends')
|
# List members/followers - fediverse only supports list members, not subscribers
|
||||||
? "friends/members" : "followers/subscribers";
|
if ($mode eq 'fos' || $mode eq 'followers') {
|
||||||
$mode = ($mode eq 'frs' || $mode eq 'friends')
|
print $stdout "-- Sorry, fediverse lists don't have followers/subscribers (privacy feature)\n";
|
||||||
? $getliurl : $getfliurl;
|
return 0;
|
||||||
$user = "&owner_screen_name=${who}&slug=${lname}";
|
}
|
||||||
$who = "list $who/$lname";
|
|
||||||
|
# Check list ownership (fediverse privacy)
|
||||||
|
if ($who ne $whoami) {
|
||||||
|
print $stdout "-- Sorry, fediverse only allows access to your own list members (privacy feature)\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Look up list ID
|
||||||
|
my $list_id = &lookup_list_id($lname);
|
||||||
|
if (!$list_id) {
|
||||||
|
print $stdout "*** list '$lname' not found; use /lists to see available lists\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$what = "list members";
|
||||||
|
$mode = $getliurl;
|
||||||
|
$mode =~ s/%I/$list_id/g;
|
||||||
|
$user = ""; # No additional parameters needed
|
||||||
|
$who = "list $lname";
|
||||||
}
|
}
|
||||||
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
|
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
|
||||||
$countmaybe += 0;
|
$countmaybe += 0;
|
||||||
@@ -3533,14 +3552,10 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
|||||||
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
|
$countmaybe =~ s/[^\d]//g if (length($countmaybe));
|
||||||
$countmaybe += 0;
|
$countmaybe += 0;
|
||||||
|
|
||||||
my $my_json_ref = &grabjson($boostsofmeurl, 0, 0, $countmaybe);
|
# "Reposts of me" not available in fediverse (privacy feature)
|
||||||
&dt_tdisplay($my_json_ref, "rtsofme");
|
print $stdout "-- Sorry, fediverse doesn't provide 'reposts of me' (privacy feature)\n";
|
||||||
if ($mode eq 're') {
|
|
||||||
$_ = '/re'; # and fall through ...
|
|
||||||
} else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (m#^/rts?of\s+([zZ]?[a-zA-Z]?[0-9]+)$# && !$noreblogs) {
|
if (m#^/rts?of\s+([zZ]?[a-zA-Z]?[0-9]+)$# && !$noreblogs) {
|
||||||
my $code = lc($1);
|
my $code = lc($1);
|
||||||
my $post = &get_post($code);
|
my $post = &get_post($code);
|
||||||
@@ -3946,18 +3961,9 @@ EOF
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $r = &postjson(
|
# List subscriptions not available in fediverse (privacy feature)
|
||||||
($m ne 'lfollow') ? $delfliurl : $crefliurl,
|
print $stdout "-- Sorry, fediverse doesn't support list subscriptions (privacy feature)\n";
|
||||||
"owner_screen_name=$uname&slug=$lname");
|
print $stdout "-- You can only access your own lists, not follow others' lists\n";
|
||||||
if ($r) {
|
|
||||||
my $t = ($m eq 'lfollow') ? "" : "un";
|
|
||||||
print $stdout &wwrap(
|
|
||||||
"*** ok, you are now ${t}marked as a follower of $uname/${lname}.\n");
|
|
||||||
my $c = ($t eq 'un') ? "off" : "on";
|
|
||||||
$t = ($t eq 'un') ? "remove from" : "add to";
|
|
||||||
print $stdout &wwrap(
|
|
||||||
"--- to also $t your timeline, use /list${c}\n");
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4099,9 +4105,23 @@ EOF
|
|||||||
$countmaybe += 0;
|
$countmaybe += 0;
|
||||||
$uname ||= $whoami;
|
$uname ||= $whoami;
|
||||||
|
|
||||||
my $my_json_ref = &grabjson(
|
# In fediverse, can only access your own lists (privacy feature)
|
||||||
"${statusliurl}?owner_screen_name=${uname}&slug=${lname}",
|
if ($uname ne $whoami) {
|
||||||
0, 0, $countmaybe, undef, 1);
|
print $stdout "-- Sorry, fediverse only allows access to your own lists (privacy feature)\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Look up list ID by title
|
||||||
|
my $list_id = &lookup_list_id($lname);
|
||||||
|
if (!$list_id) {
|
||||||
|
print $stdout "*** list '$lname' not found; use /lists to see available lists\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get list timeline using proper fediverse endpoint
|
||||||
|
my $list_timeline_url = $statusliurl;
|
||||||
|
$list_timeline_url =~ s/%I/$list_id/g;
|
||||||
|
my $my_json_ref = &grabjson($list_timeline_url, 0, 0, $countmaybe, undef, 1);
|
||||||
&dt_tdisplay($my_json_ref, "again");
|
&dt_tdisplay($my_json_ref, "again");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -6186,7 +6206,7 @@ sub updatest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $return = &backticks($baseagent, '/dev/null', undef,
|
my $return = &backticks($baseagent, '/dev/null', undef,
|
||||||
($rt_id) ? "$reblogurl/${rt_id}.json" : $update,
|
($rt_id) ? ($reblogurl =~ s/%I/$rt_id/gr) : $update,
|
||||||
$i, 0, @wend);
|
$i, 0, @wend);
|
||||||
print $stdout "-- return --\n$return\n-- return --\n"
|
print $stdout "-- return --\n$return\n-- return --\n"
|
||||||
if ($superverbose);
|
if ($superverbose);
|
||||||
@@ -7244,6 +7264,29 @@ sub lookup_account_id {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub lookup_list_id {
|
||||||
|
my $list_title = shift;
|
||||||
|
return unless ($list_title);
|
||||||
|
|
||||||
|
print $stdout "-- DEBUG: Looking up list ID for title: $list_title\n" if ($verbose);
|
||||||
|
|
||||||
|
# Get all lists for current user
|
||||||
|
my $lists_result = &grabjson($getlisurl, 0, 0, 0, undef, 1);
|
||||||
|
|
||||||
|
if ($lists_result && ref($lists_result) eq 'ARRAY') {
|
||||||
|
for my $list (@{$lists_result}) {
|
||||||
|
my $title = $list->{'title'} || '';
|
||||||
|
if (lc($title) eq lc($list_title)) {
|
||||||
|
print $stdout "-- DEBUG: Found list ID: " . $list->{'id'} . " for $list_title\n" if ($verbose);
|
||||||
|
return $list->{'id'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print $stdout "-- DEBUG: Could not find list ID for title: $list_title\n" if ($verbose);
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
sub defaulteventhandle {
|
sub defaulteventhandle {
|
||||||
(&flag_default_call, return) if ($multi_module_context);
|
(&flag_default_call, return) if ($multi_module_context);
|
||||||
my $event_ref = shift;
|
my $event_ref = shift;
|
||||||
|
|||||||
Reference in New Issue
Block a user