pterotype/inc/blocks.php

36 lines
940 B
PHP
Raw Normal View History

2018-09-04 17:28:40 +00:00
<?php
namespace blocks;
/*
If an actor is in another actor's block list, any activities
from the blocked actor that go into the blocking actors' inbox
get ignored
*/
function create_block( $actor_id, $blocked_actor_url ) {
global $wpdb;
$res = $wpdb->insert(
2018-09-19 15:16:41 +00:00
'pterotype_activitypub_blocks',
2018-09-04 17:28:40 +00:00
array( 'actor_id' => $actor_id, 'blocked_actor_url' => $blocked_actor_url )
);
if ( !$res ) {
2018-09-19 15:16:41 +00:00
return new \WP_Error( 'db_error', __( 'Error inserting block row', 'pterotype' ) );
2018-09-04 17:28:40 +00:00
}
}
function create_blocks_table() {
global $wpdb;
$wpdb->query(
"
2018-09-19 15:16:41 +00:00
CREATE TABLE IF NOT EXISTS pterotype_activitypub_blocks(
2018-09-04 17:28:40 +00:00
actor_id INT UNSIGNED NOT NULL,
blocked_actor_url TEXT NOT NULL,
2018-09-19 12:54:07 +00:00
FOREIGN KEY blocks_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
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
2018-09-04 17:28:40 +00:00
"
);
}
?>