]> git.mxchange.org Git - friendica.git/commitdiff
[Database version 1498] New table "diaspora-contact" for Diaspora contacts (duh)
authorMichael <heluecht@pirati.ca>
Sat, 28 Aug 2021 07:10:27 +0000 (07:10 +0000)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 5 Dec 2022 05:00:49 +0000 (00:00 -0500)
- Remove duplicated "author-uri-id" keys in view declarations

database.sql
doc/database.md
doc/database/db_diaspora-contact.md [new file with mode: 0644]
static/dbstructure.config.php
static/dbview.config.php

index 7b3156f6f7c8d4cab53fa3898ca4759836b7eb5b..35831813469b5397b64fb9a626f30cca2184a7da 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2022.12-dev (Giant Rhubarb)
--- DB_UPDATE_VERSION 1497
+-- DB_UPDATE_VERSION 1498
 -- ------------------------------------------
 
 
@@ -578,6 +578,40 @@ CREATE TABLE IF NOT EXISTS `delayed-post` (
        FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
 
+--
+-- TABLE diaspora-contact
+--
+CREATE TABLE IF NOT EXISTS `diaspora-contact` (
+       `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
+       `addr` varchar(255) COMMENT '',
+       `alias` varchar(255) COMMENT '',
+       `nick` varchar(255) COMMENT '',
+       `name` varchar(255) COMMENT '',
+       `given-name` varchar(255) COMMENT '',
+       `family-name` varchar(255) COMMENT '',
+       `photo` varchar(255) COMMENT '',
+       `photo-medium` varchar(255) COMMENT '',
+       `photo-small` varchar(255) COMMENT '',
+       `batch` varchar(255) COMMENT '',
+       `notify` varchar(255) COMMENT '',
+       `poll` varchar(255) COMMENT '',
+       `subscribe` varchar(255) COMMENT '',
+       `searchable` boolean COMMENT '',
+       `pubkey` text COMMENT '',
+       `gsid` int unsigned COMMENT 'Global Server ID',
+       `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
+       `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
+       `interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
+       `interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
+       `post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
+        PRIMARY KEY(`uri-id`),
+        UNIQUE INDEX `addr` (`addr`),
+        INDEX `alias` (`alias`),
+        INDEX `gsid` (`gsid`),
+       FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+       FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
+
 --
 -- TABLE diaspora-interaction
 --
@@ -3006,3 +3040,37 @@ CREATE VIEW `profile_field-view` AS SELECT
        `profile_field`.`edited` AS `edited`
        FROM `profile_field`
                        INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
+
+--
+-- VIEW diaspora-contact-view
+--
+DROP VIEW IF EXISTS `diaspora-contact-view`;
+CREATE VIEW `diaspora-contact-view` AS SELECT 
+       `diaspora-contact`.`uri-id` AS `uri-id`,
+       `item-uri`.`uri` AS `url`,
+       `item-uri`.`guid` AS `guid`,
+       `diaspora-contact`.`addr` AS `addr`,
+       `diaspora-contact`.`alias` AS `alias`,
+       `diaspora-contact`.`nick` AS `nick`,
+       `diaspora-contact`.`name` AS `name`,
+       `diaspora-contact`.`given-name` AS `given-name`,
+       `diaspora-contact`.`family-name` AS `family-name`,
+       `diaspora-contact`.`photo` AS `photo`,
+       `diaspora-contact`.`photo-medium` AS `photo-medium`,
+       `diaspora-contact`.`photo-small` AS `photo-small`,
+       `diaspora-contact`.`batch` AS `batch`,
+       `diaspora-contact`.`notify` AS `notify`,
+       `diaspora-contact`.`poll` AS `poll`,
+       `diaspora-contact`.`subscribe` AS `subscribe`,
+       `diaspora-contact`.`searchable` AS `searchable`,
+       `diaspora-contact`.`pubkey` AS `pubkey`,
+       `gserver`.`url` AS `baseurl`,
+       `diaspora-contact`.`gsid` AS `gsid`,
+       `diaspora-contact`.`created` AS `created`,
+       `diaspora-contact`.`updated` AS `updated`,
+       `diaspora-contact`.`interacting_count` AS `interacting_count`,
+       `diaspora-contact`.`interacted_count` AS `interacted_count`,
+       `diaspora-contact`.`post_count` AS `post_count`
+       FROM `diaspora-contact`
+                       INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
+                       LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;
index ec8d16b2cdb4d1ce057cf91cddea4e4812ced1dd..8d460f772a457549a5451661b4067c9d144eb9fe 100644 (file)
@@ -23,6 +23,7 @@ Database Tables
 | [contact-relation](help/database/db_contact-relation) | Contact relations |
 | [conv](help/database/db_conv) | private messages |
 | [delayed-post](help/database/db_delayed-post) | Posts that are about to be distributed at a later time |
+| [diaspora-contact](help/database/db_diaspora-contact) | Diaspora compatible contacts - used in the Diaspora implementation |
 | [diaspora-interaction](help/database/db_diaspora-interaction) | Signed Diaspora Interaction |
 | [endpoint](help/database/db_endpoint) | ActivityPub endpoints - used in the ActivityPub implementation |
 | [event](help/database/db_event) | Events |
diff --git a/doc/database/db_diaspora-contact.md b/doc/database/db_diaspora-contact.md
new file mode 100644 (file)
index 0000000..4beaeb0
--- /dev/null
@@ -0,0 +1,52 @@
+Table diaspora-contact
+===========
+
+Diaspora compatible contacts - used in the Diaspora implementation
+
+Fields
+------
+
+| Field             | Description                                                  | Type         | Null | Key | Default             | Extra |
+| ----------------- | ------------------------------------------------------------ | ------------ | ---- | --- | ------------------- | ----- |
+| uri-id            | Id of the item-uri table entry that contains the contact URL | int unsigned | NO   | PRI | NULL                |       |
+| addr              |                                                              | varchar(255) | YES  |     | NULL                |       |
+| alias             |                                                              | varchar(255) | YES  |     | NULL                |       |
+| nick              |                                                              | varchar(255) | YES  |     | NULL                |       |
+| name              |                                                              | varchar(255) | YES  |     | NULL                |       |
+| given-name        |                                                              | varchar(255) | YES  |     | NULL                |       |
+| family-name       |                                                              | varchar(255) | YES  |     | NULL                |       |
+| photo             |                                                              | varchar(255) | YES  |     | NULL                |       |
+| photo-medium      |                                                              | varchar(255) | YES  |     | NULL                |       |
+| photo-small       |                                                              | varchar(255) | YES  |     | NULL                |       |
+| batch             |                                                              | varchar(255) | YES  |     | NULL                |       |
+| notify            |                                                              | varchar(255) | YES  |     | NULL                |       |
+| poll              |                                                              | varchar(255) | YES  |     | NULL                |       |
+| subscribe         |                                                              | varchar(255) | YES  |     | NULL                |       |
+| searchable        |                                                              | boolean      | YES  |     | NULL                |       |
+| pubkey            |                                                              | text         | YES  |     | NULL                |       |
+| gsid              | Global Server ID                                             | int unsigned | YES  |     | NULL                |       |
+| created           |                                                              | datetime     | NO   |     | 0001-01-01 00:00:00 |       |
+| updated           |                                                              | datetime     | NO   |     | 0001-01-01 00:00:00 |       |
+| interacting_count | Number of contacts this contact interactes with              | int unsigned | YES  |     | 0                   |       |
+| interacted_count  | Number of contacts that interacted with this contact         | int unsigned | YES  |     | 0                   |       |
+| post_count        | Number of posts and comments                                 | int unsigned | YES  |     | 0                   |       |
+
+Indexes
+------------
+
+| Name    | Fields       |
+| ------- | ------------ |
+| PRIMARY | uri-id       |
+| addr    | UNIQUE, addr |
+| alias   | alias        |
+| gsid    | gsid         |
+
+Foreign Keys
+------------
+
+| Field | Target Table | Target Field |
+|-------|--------------|--------------|
+| uri-id | [item-uri](help/database/db_item-uri) | id |
+| gsid | [gserver](help/database/db_gserver) | id |
+
+Return to [database documentation](help/database)
index f8e01e51eec7e93f139c2b0f5494efbc33be6c4c..10ef6dad9155e2c747d91a57caae8b9efac2626f 100644 (file)
@@ -55,7 +55,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1497);
+       define('DB_UPDATE_VERSION', 1498);
 }
 
 return [
@@ -637,6 +637,39 @@ return [
                        "wid" => ["wid"],
                ]
        ],
+       "diaspora-contact" => [
+               "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
+               "fields" => [
+                       "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the contact URL"],
+                       "addr" => ["type" => "varchar(255)", "comment" => ""],
+                       "alias" => ["type" => "varchar(255)", "comment" => ""],
+                       "nick" => ["type" => "varchar(255)", "comment" => ""],
+                       "name" => ["type" => "varchar(255)", "comment" => ""],
+                       "given-name" => ["type" => "varchar(255)", "comment" => ""],
+                       "family-name" => ["type" => "varchar(255)", "comment" => ""],
+                       "photo" => ["type" => "varchar(255)", "comment" => ""],
+                       "photo-medium" => ["type" => "varchar(255)", "comment" => ""],
+                       "photo-small" => ["type" => "varchar(255)", "comment" => ""],
+                       "batch" => ["type" => "varchar(255)", "comment" => ""],
+                       "notify" => ["type" => "varchar(255)", "comment" => ""],
+                       "poll" => ["type" => "varchar(255)", "comment" => ""],
+                       "subscribe" => ["type" => "varchar(255)", "comment" => ""],
+                       "searchable" => ["type" => "boolean", "comment" => ""],
+                       "pubkey" => ["type" => "text", "comment" => ""],
+                       "gsid" => ["type" => "int unsigned", "foreign" => ["gserver" => "id", "on delete" => "restrict"], "comment" => "Global Server ID"],
+                       "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+                       "updated" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
+                       "interacting_count" => ["type" => "int unsigned", "default" => 0, "comment" => "Number of contacts this contact interactes with"],
+                       "interacted_count" => ["type" => "int unsigned", "default" => 0, "comment" => "Number of contacts that interacted with this contact"],
+                       "post_count" => ["type" => "int unsigned", "default" => 0, "comment" => "Number of posts and comments"],
+               ],
+               "indexes" => [
+                       "PRIMARY" => ["uri-id"],
+                       "addr" => ["UNIQUE", "addr"],
+                       "alias" => ["alias"],
+                       "gsid" => ["gsid"],
+               ]
+       ],
        "diaspora-interaction" => [
                "comment" => "Signed Diaspora Interaction",
                "fields" => [
index 66f3de3b63f556ee2e3f81a5064b156c70d1ca22..ab18e80e592be43d5b4bb187fcf6507d5f3e2d54 100644 (file)
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
                        "author-gsid" => ["author", "gsid"],
-                       "author-uri-id" => ["author", "uri-id"],
                        "owner-id" => ["post-user", "owner-id"],
                        "owner-uri-id" => ["owner", "uri-id"],
                        "owner-link" => ["owner", "url"],
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
                        "author-gsid" => ["author", "gsid"],
-                       "author-uri-id" => ["author", "uri-id"],
                        "owner-id" => ["post-thread-user", "owner-id"],
                        "owner-uri-id" => ["owner", "uri-id"],
                        "owner-link" => ["owner", "url"],
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
                        "author-gsid" => ["author", "gsid"],
-                       "author-uri-id" => ["author", "uri-id"],
                        "owner-id" => ["post", "owner-id"],
                        "owner-uri-id" => ["owner", "uri-id"],
                        "owner-link" => ["owner", "url"],
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
                        "author-gsid" => ["author", "gsid"],
-                       "author-uri-id" => ["author", "uri-id"],
                        "owner-id" => ["post-thread", "owner-id"],
                        "owner-uri-id" => ["owner", "uri-id"],
                        "owner-link" => ["owner", "url"],
                        LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
                        LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
                        LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
-                       WHERE `contact`.`uid` = 0"                      
+                       WHERE `contact`.`uid` = 0"
        ],
        "account-user-view" => [
                "fields" => [
                "query" => "FROM `profile_field`
                        INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`"
        ],
+       "diaspora-contact-view" => [
+               "fields" => [
+                       "uri-id" => ["diaspora-contact", "uri-id"],
+                       "url" => ["item-uri", "uri"],
+                       "guid" => ["item-uri", "guid"],
+                       "addr" => ["diaspora-contact", "addr"],
+                       "alias" => ["diaspora-contact", "alias"],
+                       "nick" => ["diaspora-contact", "nick"],
+                       "name" => ["diaspora-contact", "name"],
+                       "given-name" => ["diaspora-contact", "given-name"],
+                       "family-name" => ["diaspora-contact", "family-name"],
+                       "photo" => ["diaspora-contact", "photo"],
+                       "photo-medium" => ["diaspora-contact", "photo-medium"],
+                       "photo-small" => ["diaspora-contact", "photo-small"],
+                       "batch" => ["diaspora-contact", "batch"],
+                       "notify" => ["diaspora-contact", "notify"],
+                       "poll" => ["diaspora-contact", "poll"],
+                       "subscribe" => ["diaspora-contact", "subscribe"],
+                       "searchable" => ["diaspora-contact", "searchable"],
+                       "pubkey" => ["diaspora-contact", "pubkey"],
+                       "baseurl" => ["gserver", "url"],
+                       "gsid" => ["diaspora-contact", "gsid"],
+                       "created" => ["diaspora-contact", "created"],
+                       "updated" => ["diaspora-contact", "updated"],
+                       "interacting_count" => ["diaspora-contact", "interacting_count"],
+                       "interacted_count" => ["diaspora-contact", "interacted_count"],
+                       "post_count" => ["diaspora-contact", "post_count"],
+               ],
+               "query" => "FROM `diaspora-contact`
+                       INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
+                       LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`"
+       ],
 ];
-