account: add a list of sent follow requests

This commit is contained in:
Birte Kristina Friesel 2023-07-16 23:01:23 +02:00
parent 49beb09229
commit 19cd9f7a8d
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
6 changed files with 505 additions and 108 deletions

View file

@ -1761,6 +1761,25 @@ my @migrations = (
} }
); );
}, },
# v42 -> v43
# list sent and received follow requests
sub {
my ($db) = @_;
$db->query(
qq{
alter view follow_requests rename to rx_follow_requests;
create view tx_follow_requests as select
relations.subject_id as self_id,
users.id as id,
users.name as name
from relations
join users on relations.object_id = users.id
where predicate = 2;
update schema_version set version = 43;
}
);
},
); );
# TODO add 'hafas' column to in_transit (and maybe journeys? undo/redo needs something to work with...) # TODO add 'hafas' column to in_transit (and maybe journeys? undo/redo needs something to work with...)

View file

@ -547,12 +547,24 @@ sub social_list {
my $kind = $self->stash('kind'); my $kind = $self->stash('kind');
my $user = $self->current_user; my $user = $self->current_user;
if ( $kind eq 'follow-requests' ) { if ( $kind eq 'follow-requests-received' ) {
my @follow_reqs my @follow_reqs
= $self->users->get_follow_requests( uid => $user->{id} ); = $self->users->get_follow_requests( uid => $user->{id} );
$self->render( $self->render(
'social_list', 'social_list',
type => 'follow-requests', type => 'follow-requests-received',
entries => [@follow_reqs],
notifications => $user->{notifications},
);
}
elsif ( $kind eq 'follow-requests-sent' ) {
my @follow_reqs = $self->users->get_follow_requests(
uid => $user->{id},
sent => 1
);
$self->render(
'social_list',
type => 'follow-requests-sent',
entries => [@follow_reqs], entries => [@follow_reqs],
notifications => $user->{notifications}, notifications => $user->{notifications},
); );
@ -994,10 +1006,10 @@ sub change_name {
return; return;
} }
# The users table has a unique constraint on the "name" column, so having # The users table has a unique constraint on the "name" column, so having
# two users with the same name is not possible. The race condition # two users with the same name is not possible. The race condition
# between the user_name_exists check in is_name_invalid and this # between the user_name_exists check in is_name_invalid and this
# change_name call is harmless. # change_name call is harmless.
my $success = $self->users->change_name( my $success = $self->users->change_name(
uid => $self->current_user->{id}, uid => $self->current_user->{id},
name => $new_name name => $new_name
@ -1240,20 +1252,25 @@ sub confirm_mail {
} }
sub account { sub account {
my ($self) = @_; my ($self) = @_;
my $uid = $self->current_user->{id}; my $uid = $self->current_user->{id};
my $follow_requests = $self->users->has_follow_requests( uid => $uid ); my $rx_follow_requests = $self->users->has_follow_requests( uid => $uid );
my $followers = $self->users->has_followers( uid => $uid ); my $tx_follow_requests = $self->users->has_follow_requests(
my $following = $self->users->has_followees( uid => $uid ); uid => $uid,
my $blocked = $self->users->has_blocked_users( uid => $uid ); sent => 1
);
my $followers = $self->users->has_followers( uid => $uid );
my $following = $self->users->has_followees( uid => $uid );
my $blocked = $self->users->has_blocked_users( uid => $uid );
$self->render( $self->render(
'account', 'account',
api_token => $self->users->get_api_token( uid => $uid ), api_token => $self->users->get_api_token( uid => $uid ),
num_follow_requests => $follow_requests, num_rx_follow_requests => $rx_follow_requests,
num_followers => $followers, num_tx_follow_requests => $tx_follow_requests,
num_following => $following, num_followers => $followers,
num_blocked => $blocked, num_following => $following,
num_blocked => $blocked,
); );
$self->users->mark_seen( uid => $uid ); $self->users->mark_seen( uid => $uid );
} }

View file

@ -809,8 +809,8 @@ sub get_relation {
} }
return; return;
#my $res_h = $db->select( 'relations', ['subject_id', 'predicate'], #my $res_h = $db->select( 'relations', ['subject_id', 'predicate'],
# { subject_id => [$uid, $target], object_id => [$target, $target] } )->hash; # { subject_id => [$uid, $target], object_id => [$target, $target] } )->hash;
} }
sub update_notifications { sub update_notifications {
@ -1096,11 +1096,12 @@ sub has_followers {
sub get_follow_requests { sub get_follow_requests {
my ( $self, %opt ) = @_; my ( $self, %opt ) = @_;
my $db = $opt{db} // $self->{pg}->db; my $db = $opt{db} // $self->{pg}->db;
my $uid = $opt{uid}; my $uid = $opt{uid};
my $table = $opt{sent} ? 'tx_follow_requests' : 'rx_follow_requests';
my $res my $res
= $db->select( 'follow_requests', [ 'id', 'name' ], { self_id => $uid } ); = $db->select( $table, [ 'id', 'name' ], { self_id => $uid } );
return $res->hashes->each; return $res->hashes->each;
} }
@ -1108,11 +1109,12 @@ sub get_follow_requests {
sub has_follow_requests { sub has_follow_requests {
my ( $self, %opt ) = @_; my ( $self, %opt ) = @_;
my $db = $opt{db} // $self->{pg}->db; my $db = $opt{db} // $self->{pg}->db;
my $uid = $opt{uid}; my $uid = $opt{uid};
my $table = $opt{sent} ? 'tx_follow_requests' : 'rx_follow_requests';
return $db->select( 'follow_requests', 'count(*) as count', return $db->select( $table, 'count(*) as count', { self_id => $uid } )
{ self_id => $uid } )->hash->{count}; ->hash->{count};
} }
sub get_followees { sub get_followees {

View file

@ -90,12 +90,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
$u->request_follow( $u->request_follow(
uid => $uid1, uid => $uid1,
@ -122,16 +150,48 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 1 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 1 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 1 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 1 ); 1
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 1 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
1
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 1 );
is_deeply( is_deeply(
[ $u->get_follow_requests( uid => $uid2 ) ], [ $u->get_follow_requests( uid => $uid2 ) ],
[ { id => $uid1, name => 'test1' } ] [ { id => $uid1, name => 'test1' } ]
); );
is_deeply(
[ $u->get_follow_requests( uid => $uid1, sent => 1 ) ],
[ { id => $uid2, name => 'test2' } ]
);
$u->reject_follow_request( $u->reject_follow_request(
uid => $uid2, uid => $uid2,
@ -158,10 +218,24 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->get( uid => $uid1 )->{notifications}, 0 ); uid => $uid1,
is( $u->get( uid => $uid2 )->{notifications}, 0 ); sent => 1
),
0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
$u->request_follow( $u->request_follow(
uid => $uid1, uid => $uid1,
@ -188,16 +262,48 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 1 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 1 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 1 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 1 ); 1
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 1 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
1
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 1 );
is_deeply( is_deeply(
[ $u->get_follow_requests( uid => $uid2 ) ], [ $u->get_follow_requests( uid => $uid2 ) ],
[ { id => $uid1, name => 'test1' } ] [ { id => $uid1, name => 'test1' } ]
); );
is_deeply(
[ $u->get_follow_requests( uid => $uid1, sent => 1 ) ],
[ { id => $uid2, name => 'test2' } ]
);
$u->accept_follow_request( $u->accept_follow_request(
uid => $uid2, uid => $uid2,
@ -224,12 +330,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 1 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
is_deeply( is_deeply(
[ $u->get_followers( uid => $uid2 ) ], [ $u->get_followers( uid => $uid2 ) ],
[ [
@ -273,12 +407,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
$u->request_follow( $u->request_follow(
uid => $uid1, uid => $uid1,
@ -325,12 +487,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 1 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 1 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
is_deeply( is_deeply(
[ $u->get_blocked_users( uid => $uid2 ) ], [ $u->get_blocked_users( uid => $uid2 ) ],
[ { id => $uid1, name => 'test1' } ] [ { id => $uid1, name => 'test1' } ]
@ -361,12 +551,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
$u->block( $u->block(
uid => $uid2, uid => $uid2,
@ -393,12 +611,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 1 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 1 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
is_deeply( is_deeply(
[ $u->get_blocked_users( uid => $uid2 ) ], [ $u->get_blocked_users( uid => $uid2 ) ],
[ { id => $uid1, name => 'test1' } ] [ { id => $uid1, name => 'test1' } ]
@ -429,12 +675,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
$u->request_follow( $u->request_follow(
uid => $uid1, uid => $uid1,
@ -465,12 +739,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 1 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
is_deeply( is_deeply(
[ $u->get_followers( uid => $uid2 ) ], [ $u->get_followers( uid => $uid2 ) ],
[ [
@ -514,12 +816,40 @@ is( scalar $u->get_followees( uid => $uid1 ), 0 );
is( scalar $u->get_followees( uid => $uid2 ), 0 ); is( scalar $u->get_followees( uid => $uid2 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid1 ), 0 );
is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); is( scalar $u->get_follow_requests( uid => $uid2 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); is(
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); scalar $u->get_follow_requests(
is( $u->has_follow_requests( uid => $uid1 ), 0 ); uid => $uid1,
is( $u->has_follow_requests( uid => $uid2 ), 0 ); sent => 1
is( $u->get( uid => $uid1 )->{notifications}, 0 ); ),
is( $u->get( uid => $uid2 )->{notifications}, 0 ); 0
);
is(
scalar $u->get_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( scalar $u->get_blocked_users( uid => $uid1 ), 0 );
is( scalar $u->get_blocked_users( uid => $uid2 ), 0 );
is( $u->has_follow_requests( uid => $uid1 ), 0 );
is( $u->has_follow_requests( uid => $uid2 ), 0 );
is(
$u->has_follow_requests(
uid => $uid1,
sent => 1
),
0
);
is(
$u->has_follow_requests(
uid => $uid2,
sent => 1
),
0
);
is( $u->get( uid => $uid1 )->{notifications}, 0 );
is( $u->get( uid => $uid2 )->{notifications}, 0 );
$t->app->pg->db->query('drop schema travelynx_test_21 cascade'); $t->app->pg->db->query('drop schema travelynx_test_21 cascade');
done_testing(); done_testing();

View file

@ -92,10 +92,10 @@
% } % }
% elsif ($acc->{accept_follow_requests}) { % elsif ($acc->{accept_follow_requests}) {
<span>Accounts können dir auf Anfrage folgen <span>Accounts können dir auf Anfrage folgen
% if ($num_follow_requests == 1) { % if ($num_rx_follow_requests == 1) {
<a href="/account/social/follow-requests"><strong>eine</strong> offene Anfrage</a> <a href="/account/social/follow-requests"><strong>eine</strong> offene Anfrage</a>
% } elsif ($num_follow_requests) { % } elsif ($num_rx_follow_requests) {
<a href="/account/social/follow-requests"><strong><%= $num_follow_requests %></strong> offene Anfragen</a> <a href="/account/social/follow-requests"><strong><%= $num_rx_follow_requests %></strong> offene Anfragen</a>
% } % }
</span> </span>
% } % }
@ -179,7 +179,7 @@
</div> </div>
</div> </div>
% if ($num_follow_requests or $num_followers or $num_following or $num_blocked) { % if ($num_rx_follow_requests or $num_tx_follow_requests or $num_followers or $num_following or $num_blocked) {
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<h2>Interaktion</h2> <h2>Interaktion</h2>
@ -190,14 +190,24 @@
<tr> <tr>
<th scope="row">Anfragen</th> <th scope="row">Anfragen</th>
<td> <td>
% if ($num_follow_requests == 0) { % if ($num_rx_follow_requests == 0) {
<span style="color: #999999;">keine offen</span> <span style="color: #999999;">keine eingehend</span>
% } % }
% elsif ($num_follow_requests == 1) { % elsif ($num_rx_follow_requests == 1) {
<a href="/account/social/follow-requests"><strong>ein</strong> Account</a> <a href="/account/social/follow-requests-received"><strong>eine</strong> eingehend</a>
% } % }
% else { % else {
<a href="/account/social/follow-requests"><strong><%= $num_follow_requests %></strong> Accounts</a> <a href="/account/social/follow-requests-received"><strong><%= $num_rx_follow_requests %></strong> eingehend</a>
% }
<br/>
% if ($num_tx_follow_requests == 0) {
<span style="color: #999999;">keine ausgehend</span>
% }
% elsif ($num_tx_follow_requests == 1) {
<a href="/account/social/follow-requests-sent"><strong>eine</strong> ausgehend</a>
% }
% else {
<a href="/account/social/follow-requests-sent"><strong><%= $num_tx_follow_requests %></strong> ausgehend</a>
% } % }
</td> </td>
</tr> </tr>

View file

@ -2,10 +2,10 @@
%= csrf_field %= csrf_field
%= hidden_field redirect_to => '/account' %= hidden_field redirect_to => '/account'
% my $count = scalar @{$entries}; % my $count = scalar @{$entries};
% if ($type eq 'follow-requests') { % if ($type eq 'follow-requests-received') {
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<h2>Folge-Anfragen</h2> <h2>Erhaltene Folge-Anfragen</h2>
</div> </div>
</div> </div>
% if ($notifications) { % if ($notifications) {
@ -52,6 +52,18 @@
</div> </div>
--> -->
% } % }
% elsif ($type eq 'follow-requests-sent') {
<div class="row">
<div class="col s12">
<h2>Gestellte Folge-Anfragen</h2>
</div>
</div>
<div class="row center-align">
<div class="col s12">
<i class="material-icons">cancel</i><br/> Zurücknehmen
</div>
</div>
% }
% elsif ($type eq 'followers') { % elsif ($type eq 'followers') {
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
@ -168,7 +180,7 @@
% for my $entry (@{$entries}) { % for my $entry (@{$entries}) {
<tr> <tr>
<td><a href="/p/<%= $entry->{name} %>"><%= $entry->{name} %></a></td> <td><a href="/p/<%= $entry->{name} %>"><%= $entry->{name} %></a></td>
% if ($type eq 'follow-requests') { % if ($type eq 'follow-requests-received') {
<td class="right-align"> <td class="right-align">
<button class="btn-flat waves-effect waves-light" type="submit" name="block" value="<%= $entry->{id} %>"> <button class="btn-flat waves-effect waves-light" type="submit" name="block" value="<%= $entry->{id} %>">
<i class="material-icons" aria-label="blockieren">block</i> <i class="material-icons" aria-label="blockieren">block</i>
@ -185,6 +197,13 @@
</button> </button>
</td> </td>
% } % }
% elsif ($type eq 'follow-requests-sent') {
<td class="right-align">
<button class="btn-flat waves-effect waves-light" type="submit" name="cancel_follow_request" value="<%= $entry->{id} %>">
<i class="material-icons" aria-label="zurücknehmen">cancel</i>
</button>
</td>
% }
% elsif ($type eq 'followers') { % elsif ($type eq 'followers') {
<td class="right-align"> <td class="right-align">
<button class="btn-flat waves-effect waves-light" type="submit" name="block" value="<%= $entry->{id} %>"> <button class="btn-flat waves-effect waves-light" type="submit" name="block" value="<%= $entry->{id} %>">