pterotype/inc/following.php

37 lines
999 B
PHP
Raw Normal View History

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(
2018-09-19 15:16:41 +00:00
'pterotype_activitypub_following',
array( 'actor_id' => $actor_id,
2018-09-19 12:54:07 +00:00
'object_id' => wp_json_encode( $object ),
'state' => $PENDING
)
2018-09-04 06:01:34 +00:00
);
}
function create_following_table() {
global $wpdb;
$wpdb->query(
"
2018-09-19 15:16:41 +00:00
CREATE TABLE IF NOT EXISTS pterotype_activitypub_following(
2018-09-04 06:01:34 +00:00
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)
2018-09-19 15:16:41 +00:00
REFERENCES pterotype_activitypub_actors(id),
2018-09-19 12:54:07 +00:00
FOREIGN KEY following_object_fk(object_id)
2018-09-19 15:16:41 +00:00
REFERENCES pterotype_activitypub_objects(id)
2018-09-19 12:54:07 +00:00
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
2018-09-04 06:01:34 +00:00
"
);
}
?>