2018-12-08 00:02:18 +01:00
|
|
|
<?php
|
|
|
|
|
2018-12-09 22:20:30 +01:00
|
|
|
class Db_Activitypub_Followers {
|
2018-12-08 00:02:18 +01:00
|
|
|
|
2018-12-20 11:33:08 +01:00
|
|
|
public static function get_followers( $author_id ) {
|
|
|
|
return get_user_option( 'activitypub_followers', $author_id );
|
2018-12-08 00:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function add_follower( $actor, $author_id ) {
|
|
|
|
$followers = get_user_option( 'activitypub_followers', $author_id );
|
|
|
|
|
|
|
|
if ( ! is_array( $followers ) ) {
|
|
|
|
$followers = array( $actor );
|
|
|
|
} else {
|
|
|
|
$followers[] = $actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
$followers = array_unique( $followers );
|
|
|
|
|
|
|
|
update_user_meta( $author_id, 'activitypub_followers', $followers );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function remove_follower( $actor, $author_id ) {
|
|
|
|
$followers = get_user_option( 'activitypub_followers', $author_id );
|
|
|
|
|
|
|
|
foreach ( $followers as $key => $value ) {
|
|
|
|
if ( $value === $actor) {
|
|
|
|
unset( $followers[$key] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update_user_meta( $author_id, 'activitypub_followers', $followers );
|
|
|
|
}
|
|
|
|
}
|