2018-09-04 06:01:34 +00:00
|
|
|
<?php
|
|
|
|
namespace following;
|
|
|
|
|
|
|
|
$PENDING = 'PENDING';
|
|
|
|
$FOLLOWING = 'FOLLOWING';
|
|
|
|
|
2018-09-19 12:54:07 +00:00
|
|
|
function request_follow( $actor_id, $object_id ) {
|
2018-09-04 06:01:34 +00:00
|
|
|
global $wpdb;
|
|
|
|
return $wpdb->insert(
|
|
|
|
'activitypub_following',
|
2018-09-05 04:21:22 +00:00
|
|
|
array( 'actor_id' => $actor_id,
|
2018-09-19 12:54:07 +00:00
|
|
|
'object_id' => wp_json_encode( $object ),
|
2018-09-05 04:21:22 +00:00
|
|
|
'state' => $PENDING
|
|
|
|
)
|
2018-09-04 06:01:34 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_following_table() {
|
|
|
|
global $wpdb;
|
|
|
|
$wpdb->query(
|
|
|
|
"
|
|
|
|
CREATE TABLE IF NOT EXISTS activitypub_following(
|
|
|
|
actor_id INT UNSIGNED NOT NULL,
|
2018-09-19 12:54:07 +00:00
|
|
|
object_id INT UNSIGNED NOT NULL,
|
2018-09-04 06:01:34 +00:00
|
|
|
state VARCHAR(64) NOT NULL,
|
2018-09-19 12:54:07 +00:00
|
|
|
PRIMARY KEY (actor_id, object_id),
|
|
|
|
FOREIGN KEY following_actor_fk(actor_id)
|
|
|
|
REFERENCES activitypub_actors(id),
|
|
|
|
FOREIGN KEY following_object_fk(object_id)
|
|
|
|
REFERENCES activitypub_objects(id)
|
|
|
|
)
|
|
|
|
ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
2018-09-04 06:01:34 +00:00
|
|
|
"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
?>
|