aboutsummaryrefslogtreecommitdiff
path: root/lib/database.php
diff options
context:
space:
mode:
authorArno Richter <oelna@oelna.de>2023-08-16 14:52:58 +0200
committerArno Richter <oelna@oelna.de>2023-08-16 14:52:58 +0200
commit66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5 (patch)
treefa54ab21d4c6122df124459030dd5c6af723f1af /lib/database.php
parentff2858b6ea8f586daa95e51ae21315f86cc5ded5 (diff)
downloadmicroblog-66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5.tar.gz
microblog-66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5.tar.bz2
microblog-66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5.zip
huge update to implement first version of activitypub support. closes #16. AP and subdir hosting are incompatible!
Diffstat (limited to 'lib/database.php')
-rw-r--r--lib/database.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/database.php b/lib/database.php
index 4e5e0cd..e64a80c 100644
--- a/lib/database.php
+++ b/lib/database.php
@@ -93,5 +93,71 @@ if($config['db_version'] == 3) {
}
}
+// v5, update for activitypub
+if($config['db_version'] == 4) {
+ try {
+ $db->exec("PRAGMA `user_version` = 5;
+ CREATE TABLE IF NOT EXISTS `followers` (
+ `id` INTEGER PRIMARY KEY NOT NULL,
+ `follower_name` TEXT NOT NULL,
+ `follower_host` TEXT NOT NULL,
+ `follower_actor` TEXT,
+ `follower_inbox` TEXT,
+ `follower_shared_inbox` TEXT,
+ `follower_added` INTEGER
+ );
+ CREATE UNIQUE INDEX `followers_users` ON followers (`follower_name`, `follower_host`);
+ CREATE INDEX `followers_shared_inboxes` ON followers (`follower_shared_inbox`);
+ ");
+ $config['db_version'] = 5;
+ } catch(PDOException $e) {
+ print 'Exception : '.$e->getMessage();
+ die('cannot upgrade database table to v5!');
+ }
+}
+
+// v6, update for activitypub likes and announces
+if($config['db_version'] == 5) {
+ try {
+ $db->exec("PRAGMA `user_version` = 6;
+ CREATE TABLE IF NOT EXISTS `activities` (
+ `id` INTEGER PRIMARY KEY NOT NULL,
+ `activity_actor_name` TEXT NOT NULL,
+ `activity_actor_host` TEXT NOT NULL,
+ `activity_type` TEXT NOT NULL,
+ `activity_object_id` INTEGER NOT NULL,
+ `activity_updated` INTEGER
+ );
+ CREATE INDEX `activities_objects` ON activities (`activity_object_id`);
+ CREATE UNIQUE INDEX `activities_unique` ON activities (`activity_actor_name`, `activity_actor_host`, `activity_type`, `activity_object_id`);
+ ");
+ $config['db_version'] = 6;
+ } catch(PDOException $e) {
+ print 'Exception : '.$e->getMessage();
+ die('cannot upgrade database table to v6!');
+ }
+}
+
+// v7, update for activitypub key storage
+if($config['db_version'] == 6) {
+ try {
+ $db->exec("PRAGMA `user_version` = 6;
+ CREATE TABLE IF NOT EXISTS `keys` (
+ `id` INTEGER PRIMARY KEY NOT NULL,
+ `key_private` TEXT NOT NULL,
+ `key_public` TEXT NOT NULL,
+ `key_algo` TEXT DEFAULT 'sha512',
+ `key_bits` INTEGER DEFAULT 4096,
+ `key_type` TEXT DEFAULT 'rsa',
+ `key_created` INTEGER
+ );
+ ");
+ $config['db_version'] = 7;
+ } catch(PDOException $e) {
+ print 'Exception : '.$e->getMessage();
+ die('cannot upgrade database table to v7!');
+ }
+}
+
// debug: get a list of post table columns
// var_dump($db->query("PRAGMA table_info(`posts`)")->fetchAll(PDO::FETCH_COLUMN, 1));