Merge pull request #14097 from annando/enable-user-defined-channel
[friendica.git/.git] / database.sql
index b4f18a2..120edf3 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
--- Friendica 2024.03-rc (Yellow Archangel)
--- DB_UPDATE_VERSION 1557
+-- Friendica 2024.06-dev (Yellow Archangel)
+-- DB_UPDATE_VERSION 1559
 -- ------------------------------------------
 
 
@@ -1347,7 +1347,7 @@ CREATE TABLE IF NOT EXISTS `post-engagement` (
        `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
        `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
        `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
-       `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio',
+       `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio)',
        `language` char(2) COMMENT 'Language information about this post in the ISO 639-1 format',
        `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
        `size` int unsigned COMMENT 'Body size',
@@ -1471,7 +1471,7 @@ CREATE TABLE IF NOT EXISTS `post-question-option` (
 CREATE TABLE IF NOT EXISTS `post-searchindex` (
        `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
        `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
-       `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio',
+       `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio)',
        `language` char(2) COMMENT 'Language information about this post in the ISO 639-1 format',
        `searchtext` mediumtext COMMENT 'Simplified text for the full text search',
        `size` int unsigned COMMENT 'Body size',
@@ -1550,6 +1550,7 @@ CREATE TABLE IF NOT EXISTS `post-user` (
        `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
        `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
        `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
+       `restrictions` tinyint unsigned COMMENT 'Bit array of post restrictions (1 = Reply, 2 = Like, 4 = Announce)',
        `global` boolean NOT NULL DEFAULT '0' COMMENT '',
        `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
        `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
@@ -1947,6 +1948,7 @@ CREATE TABLE IF NOT EXISTS `user-contact` (
        `ignored` boolean COMMENT 'Posts from this contact are ignored',
        `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
        `hidden` boolean COMMENT 'This contact is hidden from the others',
+       `channel-only` boolean COMMENT 'This contact is displayed only in channels, but not in the network stream.',
        `is-blocked` boolean COMMENT 'User is blocked by this contact',
        `channel-frequency` tinyint unsigned COMMENT 'Controls the frequency of the appearance of this contact in channels',
        `pending` boolean COMMENT '',
@@ -2200,6 +2202,7 @@ CREATE VIEW `post-user-view` AS SELECT
        `post-content`.`location` AS `location`,
        `post-content`.`coord` AS `coord`,
        `post-content`.`sensitive` AS `sensitive`,
+       `post-user`.`restrictions` AS `restrictions`,
        `post-content`.`app` AS `app`,
        `post-content`.`object-type` AS `object-type`,
        `post-content`.`object` AS `object`,
@@ -2385,6 +2388,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
        `post-content`.`location` AS `location`,
        `post-content`.`coord` AS `coord`,
        `post-content`.`sensitive` AS `sensitive`,
+       `post-user`.`restrictions` AS `restrictions`,
        `post-content`.`app` AS `app`,
        `post-content`.`object-type` AS `object-type`,
        `post-content`.`object` AS `object`,
@@ -2876,36 +2880,6 @@ CREATE VIEW `tag-view` AS SELECT
                        LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
                        LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
 
---
--- VIEW network-item-view
---
-DROP VIEW IF EXISTS `network-item-view`;
-CREATE VIEW `network-item-view` AS SELECT 
-       `post-user`.`uri-id` AS `uri-id`,
-       `post-thread-user`.`post-user-id` AS `parent`,
-       `post-user`.`received` AS `received`,
-       `post-thread-user`.`commented` AS `commented`,
-       `post-user`.`created` AS `created`,
-       `post-user`.`uid` AS `uid`,
-       `post-thread-user`.`starred` AS `starred`,
-       `post-thread-user`.`mention` AS `mention`,
-       `post-user`.`network` AS `network`,
-       `post-user`.`unseen` AS `unseen`,
-       `post-user`.`gravity` AS `gravity`,
-       `post-user`.`contact-id` AS `contact-id`,
-       `ownercontact`.`contact-type` AS `contact-type`
-       FROM `post-user`
-                       INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
-                       STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
-                       STRAIGHT_JOIN `contact` AS `authorcontact` ON `authorcontact`.`id` = `post-thread-user`.`author-id`
-                       STRAIGHT_JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
-                       WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
-                       AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
-                       AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
-                       AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
-                       AND NOT EXISTS(SELECT `cid`    FROM `user-contact` WHERE `uid` = `post-thread-user`.`uid` AND `cid` IN (`authorcontact`.`id`, `ownercontact`.`id`) AND (`blocked` OR `ignored`))
-                       AND NOT EXISTS(SELECT `gsid`   FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
-
 --
 -- VIEW network-thread-view
 --
@@ -2931,8 +2905,8 @@ CREATE VIEW `network-thread-view` AS SELECT
                        AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
                        AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
                        AND NOT `authorcontact`.`blocked` AND NOT `ownercontact`.`blocked`
-                       AND NOT EXISTS(SELECT `cid`    FROM `user-contact` WHERE `uid` = `post-thread-user`.`uid` AND `cid` IN (`authorcontact`.`id`, `ownercontact`.`id`) AND (`blocked` OR `ignored`))
-                       AND NOT EXISTS(SELECT `gsid`   FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
+                       AND NOT EXISTS(SELECT `cid`  FROM `user-contact` WHERE `uid` = `post-thread-user`.`uid` AND `cid` IN (`post-thread-user`.`author-id`, `post-thread-user`.`owner-id`, `post-thread-user`.`causer-id`) AND (`blocked` OR `ignored` OR `channel-only`))
+                       AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = `post-thread-user`.`uid` AND `gsid` IN (`authorcontact`.`gsid`, `ownercontact`.`gsid`) AND `ignored`);
 
 --
 -- VIEW owner-view