Matthias Pfefferle
4e653f5f75
* added basic WebFinger support * added basic NodeInfo support * fully functional "follow" activity * send new posts to your followers * receive comments from your followers
34 lines
854 B
PHP
34 lines
854 B
PHP
<?php
|
|
|
|
class Db_Activitypub_Followers {
|
|
|
|
public static function get_followers( $author_id ) {
|
|
return get_user_option( 'activitypub_followers', $author_id );
|
|
}
|
|
|
|
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 );
|
|
}
|
|
}
|