Merge branch 'toot-visibility' into develop

Initial update to include hardcoded change.
Cleaner, more complete solution to be merged at later time.
develop
mj-saunders 2018-05-01 11:35:50 +00:00
commit bd07500ce1
1 changed files with 26 additions and 0 deletions

View File

@ -10,6 +10,8 @@ use RSSTootalizer::User;
use RSSTootalizer::Entry;
use RSSTootalizer::DB;
my $VERBOSE = 1;
our $config = "";
open CONFIG, "rsstootalizer.conf.json" or die "Cannot open rsstootalizer.conf.json";
{
@ -35,6 +37,9 @@ sub Error {{{
binmode STDERR, ":utf8";
binmode STDOUT, ":utf8";
if ($VERBOSE) {print STDOUT "Checking for new entries\n";}
my $new_entries = 0;
my @feeds = RSSTootalizer::Feed->all();
FEED: foreach my $feed (@feeds){
next FEED unless $feed;
@ -88,14 +93,30 @@ FEED: foreach my $feed (@feeds){
$status =~ s/^(.{497}).*$/$1.../g;
}
$data{status} = $status;
# Visibility of a toot can be 'direct', 'private', 'unlisted' or 'public'
# 'direct' and 'unlisted' are irrelevant
# 'private' posts only to followers [default]
# 'public' posts to public timelines [ethical issue?]
# [* Should be set per feed in the sql db *]
# [* Hardcoded here temporarily for testing *]
my $visibility = 'public';
$data{visibility} = $visibility;
$ENV{status} = encode_json({%data});
# encode_json breaks '\n' chars - turns them into '\\n'
# Fix them
$ENV{status} =~ s/\\\\n/\\n/g;
open(DATA, "./post_status.bash '$user->{data}->{access_token}' '$user->{data}->{instance}' |");
my $reply = "";
{
local $/ = undef;
$reply = <DATA>;
}
$new_entries += 1;
}
my %ne;
@ -106,3 +127,8 @@ FEED: foreach my $feed (@feeds){
}
RSSTootalizer::DB->doUPDATE("UPDATE `users` SET session_id = 'invalid' WHERE TIME_TO_SEC(NOW()) - TIME_TO_SEC(`valid_from`) > 60*60*4;"); # invalidate old sessions
if ($VERBOSE) {
$new_entries ? ($new_entries > 1 ? print "$new_entries new entries\n" : print "$new_entries new entry\n") : print "No new entries\n";
print STDOUT "Done\n";
}