Merge pull request #9930 from annando/no-item

The "item" table is now replaced
This commit is contained in:
Hypolite Petovan 2021-02-15 17:26:34 -05:00 committed by GitHub
commit 9e1f03ca11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 1439 additions and 1099 deletions

View file

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2021.03-dev (Red Hot Poker)
-- DB_UPDATE_VERSION 1399
-- DB_UPDATE_VERSION 1400
-- ------------------------------------------
@ -705,7 +705,6 @@ CREATE TABLE IF NOT EXISTS `item` (
`global` boolean NOT NULL DEFAULT '0' COMMENT '',
`private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
`visible` boolean NOT NULL DEFAULT '0' COMMENT '',
`moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
`deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
`contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
@ -717,9 +716,10 @@ CREATE TABLE IF NOT EXISTS `item` (
`pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
`forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`event-id` int unsigned COMMENT 'Used to link to the event.id',
`type` varchar(20) COMMENT '',
`bookmark` boolean COMMENT '',
`mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
`bookmark` boolean COMMENT 'Deprecated',
`type` varchar(20) COMMENT 'Deprecated',
`moderated` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`resource-id` varchar(32) COMMENT 'Deprecated',
`uri-hash` varchar(80) COMMENT 'Deprecated',
`iaid` int unsigned COMMENT 'Deprecated',
@ -1026,6 +1026,47 @@ CREATE TABLE IF NOT EXISTS `photo` (
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
--
-- TABLE post
--
CREATE TABLE IF NOT EXISTS `post` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
`thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
`external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
`edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
`received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
`gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
`owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
`author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
`causer-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
`post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
`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',
`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',
PRIMARY KEY(`uri-id`),
INDEX `parent-uri-id` (`parent-uri-id`),
INDEX `thr-parent-id` (`thr-parent-id`),
INDEX `external-id` (`external-id`),
INDEX `owner-id` (`owner-id`),
INDEX `author-id` (`author-id`),
INDEX `causer-id` (`causer-id`),
INDEX `vid` (`vid`),
INDEX `received` (`received`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
--
-- TABLE post-category
--
@ -1157,12 +1198,31 @@ CREATE TABLE IF NOT EXISTS `post-thread` (
CREATE TABLE IF NOT EXISTS `post-user` (
`id` int unsigned NOT NULL auto_increment,
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
`thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
`external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
`edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
`received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
`gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
`owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
`author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
`causer-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
`post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
`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',
`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',
`uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item',
`protocol` tinyint unsigned COMMENT 'Protocol used to deliver the item for this user',
`contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
`event-id` int unsigned COMMENT 'Used to link to the event.id',
`unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
`hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
`notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
`origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
`psid` int unsigned COMMENT 'ID of the permission set of this post',
PRIMARY KEY(`id`),
@ -1171,9 +1231,34 @@ CREATE TABLE IF NOT EXISTS `post-user` (
INDEX `contact-id` (`contact-id`),
INDEX `psid` (`psid`),
INDEX `uid_hidden` (`uid`,`hidden`),
INDEX `event-id` (`event-id`),
INDEX `uid_wall` (`uid`,`wall`),
INDEX `parent-uri-id` (`parent-uri-id`),
INDEX `thr-parent-id` (`thr-parent-id`),
INDEX `external-id` (`external-id`),
INDEX `owner-id` (`owner-id`),
INDEX `author-id` (`author-id`),
INDEX `causer-id` (`causer-id`),
INDEX `vid` (`vid`),
INDEX `uid_received` (`uid`,`received`),
INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
INDEX `uid_network_received` (`uid`,`network`,`received`),
INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
INDEX `authorid_received` (`author-id`,`received`),
INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
INDEX `uid_eventid` (`uid`,`event-id`),
INDEX `psid_wall` (`psid`,`wall`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`external-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`event-id`) REFERENCES `event` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data';
@ -1182,6 +1267,14 @@ CREATE TABLE IF NOT EXISTS `post-user` (
--
CREATE TABLE IF NOT EXISTS `post-thread-user` (
`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',
`author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
`causer-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
`commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
`pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
`starred` boolean NOT NULL DEFAULT '0' COMMENT '',
@ -1203,7 +1296,28 @@ CREATE TABLE IF NOT EXISTS `post-thread-user` (
INDEX `contact-id` (`contact-id`),
INDEX `psid` (`psid`),
INDEX `post-user-id` (`post-user-id`),
INDEX `owner-id` (`owner-id`),
INDEX `causer-id` (`causer-id`),
INDEX `uid_received` (`uid`,`received`),
INDEX `uid_commented` (`uid`,`commented`),
INDEX `uid_changed` (`uid`,`changed`),
INDEX `uid_contact-id` (`uid`,`contact-id`,`received`),
INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
INDEX `uid_network_received` (`uid`,`network`,`received`),
INDEX `uid_network_commented` (`uid`,`network`,`commented`),
INDEX `uid_contact-id_received` (`uid`,`contact-id`,`received`),
INDEX `author-id_received` (`author-id`,`received`),
INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
INDEX `mention_uid` (`mention`,`uid`),
INDEX `psid_wall` (`psid`,`wall`),
INDEX `received` (`received`),
INDEX `commented` (`commented`),
INDEX `changed` (`changed`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
@ -1474,44 +1588,42 @@ CREATE TABLE IF NOT EXISTS `workerqueue` (
--
DROP VIEW IF EXISTS `post-view`;
CREATE VIEW `post-view` AS SELECT
`item`.`id` AS `id`,
`item`.`id` AS `item_id`,
`post-user`.`id` AS `id`,
`item`.`id` AS `item-id`,
`post-user`.`id` AS `post-user-id`,
`item`.`uid` AS `uid`,
`item`.`parent` AS `parent`,
`item`.`uri` AS `uri`,
`item`.`uri-id` AS `uri-id`,
`item`.`parent-uri` AS `parent-uri`,
`item`.`parent-uri-id` AS `parent-uri-id`,
`item`.`thr-parent` AS `thr-parent`,
`item`.`thr-parent-id` AS `thr-parent-id`,
`item`.`guid` AS `guid`,
`item`.`type` AS `type`,
`item`.`wall` AS `wall`,
`item`.`gravity` AS `gravity`,
`item`.`extid` AS `extid`,
`item`.`created` AS `created`,
`item`.`edited` AS `edited`,
`item`.`commented` AS `commented`,
`item`.`received` AS `received`,
`item`.`changed` AS `changed`,
`item`.`post-type` AS `post-type`,
`item`.`private` AS `private`,
`item`.`pubmail` AS `pubmail`,
`item`.`moderated` AS `moderated`,
`item`.`visible` AS `visible`,
`item`.`starred` AS `starred`,
`item`.`bookmark` AS `bookmark`,
`item`.`unseen` AS `unseen`,
`item`.`deleted` AS `deleted`,
`item`.`origin` AS `origin`,
`item`.`forum_mode` AS `forum_mode`,
`item`.`mention` AS `mention`,
`item`.`global` AS `global`,
`item`.`network` AS `network`,
`item`.`vid` AS `vid`,
`item`.`psid` AS `psid`,
IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
`post-user`.`uid` AS `uid`,
`parent-post`.`id` AS `parent`,
`item-uri`.`uri` AS `uri`,
`post-user`.`uri-id` AS `uri-id`,
`parent-item-uri`.`uri` AS `parent-uri`,
`post-user`.`parent-uri-id` AS `parent-uri-id`,
`thr-parent-item-uri`.`uri` AS `thr-parent`,
`post-user`.`thr-parent-id` AS `thr-parent-id`,
`item-uri`.`guid` AS `guid`,
`post-user`.`wall` AS `wall`,
`post-user`.`gravity` AS `gravity`,
`external-item-uri`.`uri` AS `extid`,
`post-user`.`external-id` AS `external-id`,
`post-user`.`created` AS `created`,
`post-user`.`edited` AS `edited`,
`post-thread-user`.`commented` AS `commented`,
`post-user`.`received` AS `received`,
`post-thread-user`.`changed` AS `changed`,
`post-user`.`post-type` AS `post-type`,
`post-user`.`private` AS `private`,
`post-thread-user`.`pubmail` AS `pubmail`,
`post-user`.`visible` AS `visible`,
`post-thread-user`.`starred` AS `starred`,
`post-user`.`unseen` AS `unseen`,
`post-user`.`deleted` AS `deleted`,
`post-user`.`origin` AS `origin`,
`post-thread-user`.`forum_mode` AS `forum_mode`,
`post-thread-user`.`mention` AS `mention`,
`post-user`.`global` AS `global`,
`post-user`.`network` AS `network`,
`post-user`.`vid` AS `vid`,
`post-user`.`psid` AS `psid`,
IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
`post-content`.`title` AS `title`,
`post-content`.`content-warning` AS `content-warning`,
`post-content`.`raw-body` AS `raw-body`,
@ -1528,7 +1640,7 @@ CREATE VIEW `post-view` AS SELECT
`post-content`.`target-type` AS `target-type`,
`post-content`.`target` AS `target`,
`post-content`.`resource-id` AS `resource-id`,
`item`.`contact-id` AS `contact-id`,
`post-user`.`contact-id` AS `contact-id`,
`contact`.`url` AS `contact-link`,
`contact`.`addr` AS `contact-addr`,
`contact`.`name` AS `contact-name`,
@ -1543,7 +1655,7 @@ CREATE VIEW `post-view` AS SELECT
`contact`.`rel` AS `contact-rel`,
`contact`.`uid` AS `contact-uid`,
`contact`.`contact-type` AS `contact-contact-type`,
IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
`contact`.`self` AS `self`,
`contact`.`id` AS `cid`,
`contact`.`alias` AS `alias`,
@ -1553,7 +1665,7 @@ CREATE VIEW `post-view` AS SELECT
`contact`.`avatar-date` AS `avatar-date`,
`contact`.`thumb` AS `thumb`,
`contact`.`dfrn-id` AS `dfrn-id`,
`item`.`author-id` AS `author-id`,
`post-user`.`author-id` AS `author-id`,
`author`.`url` AS `author-link`,
`author`.`addr` AS `author-addr`,
IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
@ -1562,7 +1674,7 @@ CREATE VIEW `post-view` AS SELECT
`author`.`network` AS `author-network`,
`author`.`blocked` AS `author-blocked`,
`author`.`hidden` AS `author-hidden`,
`item`.`owner-id` AS `owner-id`,
`post-user`.`owner-id` AS `owner-id`,
`owner`.`url` AS `owner-link`,
`owner`.`addr` AS `owner-addr`,
IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
@ -1571,7 +1683,7 @@ CREATE VIEW `post-view` AS SELECT
`owner`.`network` AS `owner-network`,
`owner`.`blocked` AS `owner-blocked`,
`owner`.`hidden` AS `owner-hidden`,
`item`.`causer-id` AS `causer-id`,
`post-user`.`causer-id` AS `causer-id`,
`causer`.`url` AS `causer-link`,
`causer`.`addr` AS `causer-addr`,
`causer`.`name` AS `causer-name`,
@ -1586,11 +1698,11 @@ CREATE VIEW `post-view` AS SELECT
`post-delivery-data`.`queue_count` AS `delivery_queue_count`,
`post-delivery-data`.`queue_done` AS `delivery_queue_done`,
`post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
`item`.`event-id` AS `event-id`,
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
`post-user`.`event-id` AS `event-id`,
`event`.`created` AS `event-created`,
`event`.`edited` AS `event-edited`,
`event`.`start` AS `event-start`,
@ -1603,71 +1715,75 @@ CREATE VIEW `post-view` AS SELECT
`event`.`adjust` AS `event-adjust`,
`event`.`ignore` AS `event-ignore`,
`diaspora-interaction`.`interaction` AS `signed_text`,
`parent-item`.`guid` AS `parent-guid`,
`parent-item`.`network` AS `parent-network`,
`parent-item`.`author-id` AS `parent-author-id`,
`parent-item-author`.`url` AS `parent-author-link`,
`parent-item-author`.`name` AS `parent-author-name`,
`parent-item-author`.`network` AS `parent-author-network`
FROM `item`
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `item`.`uid`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `item`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id` AND `parent-item`.`uid` = `item`.`uid`
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
`parent-item-uri`.`guid` AS `parent-guid`,
`parent-post`.`network` AS `parent-network`,
`parent-post`.`author-id` AS `parent-author-id`,
`parent-post-author`.`url` AS `parent-author-link`,
`parent-post-author`.`name` AS `parent-author-name`,
`parent-post-author`.`network` AS `parent-author-network`
FROM `post-user`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
LEFT JOIN `item` ON `item`.`uri-id` = `post-user`.`uri-id` AND `item`.`uid` = `post-user`.`uid`
INNER JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
INNER JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
INNER JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
INNER JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
INNER JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
INNER JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
INNER JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
INNER JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
INNER JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
--
-- VIEW post-thread-view
--
DROP VIEW IF EXISTS `post-thread-view`;
CREATE VIEW `post-thread-view` AS SELECT
`item`.`id` AS `id`,
`item`.`id` AS `iid`,
`item`.`id` AS `item_id`,
`post-user`.`id` AS `id`,
`item`.`id` AS `item-id`,
`post-user`.`id` AS `iid`,
`post-user`.`id` AS `post-user-id`,
`post-thread-user`.`uid` AS `uid`,
`item`.`parent` AS `parent`,
`item`.`uri` AS `uri`,
`post-thread`.`uri-id` AS `uri-id`,
`item`.`parent-uri` AS `parent-uri`,
`item`.`parent-uri-id` AS `parent-uri-id`,
`item`.`thr-parent` AS `thr-parent`,
`item`.`thr-parent-id` AS `thr-parent-id`,
`item`.`guid` AS `guid`,
`item`.`type` AS `type`,
`parent-post`.`id` AS `parent`,
`item-uri`.`uri` AS `uri`,
`post-thread-user`.`uri-id` AS `uri-id`,
`parent-item-uri`.`uri` AS `parent-uri`,
`post-user`.`parent-uri-id` AS `parent-uri-id`,
`thr-parent-item-uri`.`uri` AS `thr-parent`,
`post-user`.`thr-parent-id` AS `thr-parent-id`,
`item-uri`.`guid` AS `guid`,
`post-thread-user`.`wall` AS `wall`,
`item`.`gravity` AS `gravity`,
`item`.`extid` AS `extid`,
`post-thread`.`created` AS `created`,
`item`.`edited` AS `edited`,
`post-thread`.`commented` AS `commented`,
`post-thread`.`received` AS `received`,
`post-thread`.`changed` AS `changed`,
`item`.`post-type` AS `post-type`,
`item`.`private` AS `private`,
`post-user`.`gravity` AS `gravity`,
`external-item-uri`.`uri` AS `extid`,
`post-user`.`external-id` AS `external-id`,
`post-thread-user`.`created` AS `created`,
`post-user`.`edited` AS `edited`,
`post-thread-user`.`commented` AS `commented`,
`post-thread-user`.`received` AS `received`,
`post-thread-user`.`changed` AS `changed`,
`post-user`.`post-type` AS `post-type`,
`post-user`.`private` AS `private`,
`post-thread-user`.`pubmail` AS `pubmail`,
`item`.`moderated` AS `moderated`,
`post-thread-user`.`ignored` AS `ignored`,
`item`.`visible` AS `visible`,
`post-user`.`visible` AS `visible`,
`post-thread-user`.`starred` AS `starred`,
`item`.`bookmark` AS `bookmark`,
`post-thread-user`.`unseen` AS `unseen`,
`item`.`deleted` AS `deleted`,
`post-user`.`deleted` AS `deleted`,
`post-thread-user`.`origin` AS `origin`,
`post-thread-user`.`forum_mode` AS `forum_mode`,
`item`.`mention` AS `mention`,
`item`.`global` AS `global`,
`post-thread`.`network` AS `network`,
`item`.`vid` AS `vid`,
`post-thread-user`.`mention` AS `mention`,
`post-user`.`global` AS `global`,
`post-thread-user`.`network` AS `network`,
`post-user`.`vid` AS `vid`,
`post-thread-user`.`psid` AS `psid`,
IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
IF (`post-user`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
`post-content`.`title` AS `title`,
`post-content`.`content-warning` AS `content-warning`,
`post-content`.`raw-body` AS `raw-body`,
@ -1699,7 +1815,7 @@ CREATE VIEW `post-thread-view` AS SELECT
`contact`.`rel` AS `contact-rel`,
`contact`.`uid` AS `contact-uid`,
`contact`.`contact-type` AS `contact-contact-type`,
IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`) AS `writable`,
`contact`.`self` AS `self`,
`contact`.`id` AS `cid`,
`contact`.`alias` AS `alias`,
@ -1709,7 +1825,7 @@ CREATE VIEW `post-thread-view` AS SELECT
`contact`.`avatar-date` AS `avatar-date`,
`contact`.`thumb` AS `thumb`,
`contact`.`dfrn-id` AS `dfrn-id`,
`post-thread`.`author-id` AS `author-id`,
`post-thread-user`.`author-id` AS `author-id`,
`author`.`url` AS `author-link`,
`author`.`addr` AS `author-addr`,
IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`) AS `author-name`,
@ -1718,7 +1834,7 @@ CREATE VIEW `post-thread-view` AS SELECT
`author`.`network` AS `author-network`,
`author`.`blocked` AS `author-blocked`,
`author`.`hidden` AS `author-hidden`,
`post-thread`.`owner-id` AS `owner-id`,
`post-thread-user`.`owner-id` AS `owner-id`,
`owner`.`url` AS `owner-link`,
`owner`.`addr` AS `owner-addr`,
IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`) AS `owner-name`,
@ -1727,7 +1843,7 @@ CREATE VIEW `post-thread-view` AS SELECT
`owner`.`network` AS `owner-network`,
`owner`.`blocked` AS `owner-blocked`,
`owner`.`hidden` AS `owner-hidden`,
`item`.`causer-id` AS `causer-id`,
`post-thread-user`.`causer-id` AS `causer-id`,
`causer`.`url` AS `causer-link`,
`causer`.`addr` AS `causer-addr`,
`causer`.`name` AS `causer-name`,
@ -1746,7 +1862,7 @@ CREATE VIEW `post-thread-view` AS SELECT
IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
`item`.`event-id` AS `event-id`,
`post-user`.`event-id` AS `event-id`,
`event`.`created` AS `event-created`,
`event`.`edited` AS `event-edited`,
`event`.`start` AS `event-start`,
@ -1759,27 +1875,31 @@ CREATE VIEW `post-thread-view` AS SELECT
`event`.`adjust` AS `event-adjust`,
`event`.`ignore` AS `event-ignore`,
`diaspora-interaction`.`interaction` AS `signed_text`,
`parent-item`.`guid` AS `parent-guid`,
`parent-item`.`network` AS `parent-network`,
`parent-item`.`author-id` AS `parent-author-id`,
`parent-item-author`.`url` AS `parent-author-link`,
`parent-item-author`.`name` AS `parent-author-name`,
`parent-item-author`.`network` AS `parent-author-network`
FROM `post-thread`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread`.`uri-id` AND `post-thread-user`.`origin`
`parent-item-uri`.`guid` AS `parent-guid`,
`parent-post`.`network` AS `parent-network`,
`parent-post`.`author-id` AS `parent-author-id`,
`parent-post-author`.`url` AS `parent-author-link`,
`parent-post-author`.`name` AS `parent-author-name`,
`parent-post-author`.`network` AS `parent-author-network`
FROM `post-thread-user`
INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
LEFT JOIN `item` ON `item`.`uri-id` = `post-thread-user`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
INNER JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
INNER JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
INNER JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
INNER JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
INNER JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
INNER JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
INNER JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
INNER JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
--
-- VIEW category-view
@ -1788,14 +1908,11 @@ DROP VIEW IF EXISTS `category-view`;
CREATE VIEW `category-view` AS SELECT
`post-category`.`uri-id` AS `uri-id`,
`post-category`.`uid` AS `uid`,
`item-uri`.`uri` AS `uri`,
`item-uri`.`guid` AS `guid`,
`post-category`.`type` AS `type`,
`post-category`.`tid` AS `tid`,
`tag`.`name` AS `name`,
`tag`.`url` AS `url`
FROM `post-category`
INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
--
@ -1804,15 +1921,12 @@ CREATE VIEW `category-view` AS SELECT
DROP VIEW IF EXISTS `tag-view`;
CREATE VIEW `tag-view` AS SELECT
`post-tag`.`uri-id` AS `uri-id`,
`item-uri`.`uri` AS `uri`,
`item-uri`.`guid` AS `guid`,
`post-tag`.`type` AS `type`,
`post-tag`.`tid` AS `tid`,
`post-tag`.`cid` AS `cid`,
CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
FROM `post-tag`
INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
@ -1821,28 +1935,27 @@ CREATE VIEW `tag-view` AS SELECT
--
DROP VIEW IF EXISTS `network-item-view`;
CREATE VIEW `network-item-view` AS SELECT
`item`.`parent-uri-id` AS `uri-id`,
`item`.`parent-uri` AS `uri`,
`item`.`parent` AS `parent`,
`item`.`received` AS `received`,
`item`.`commented` AS `commented`,
`item`.`created` AS `created`,
`item`.`uid` AS `uid`,
`item`.`starred` AS `starred`,
`item`.`mention` AS `mention`,
`item`.`network` AS `network`,
`item`.`unseen` AS `unseen`,
`item`.`gravity` AS `gravity`,
`item`.`contact-id` AS `contact-id`,
`post-user`.`uri-id` AS `uri-id`,
`parent-post`.`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 `item`
INNER JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `parent-item`.`contact-id`
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `parent-item`.`uid`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `parent-item`.`uid` AND `author`.`cid` = `parent-item`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `parent-item`.`uid` AND `owner`.`cid` = `parent-item`.`owner-id`
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `parent-item`.`owner-id`
WHERE `parent-item`.`visible` AND NOT `parent-item`.`deleted` AND NOT `parent-item`.`moderated`
FROM `post-user`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
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 (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
@ -1853,27 +1966,25 @@ CREATE VIEW `network-item-view` AS SELECT
--
DROP VIEW IF EXISTS `network-thread-view`;
CREATE VIEW `network-thread-view` AS SELECT
`post-thread`.`uri-id` AS `uri-id`,
`item`.`uri` AS `uri`,
`item`.`parent-uri-id` AS `parent-uri-id`,
`item`.`id` AS `parent`,
`post-thread`.`received` AS `received`,
`post-thread`.`commented` AS `commented`,
`post-thread`.`created` AS `created`,
`post-thread-user`.`uri-id` AS `uri-id`,
`parent-post`.`id` AS `parent`,
`post-thread-user`.`received` AS `received`,
`post-thread-user`.`commented` AS `commented`,
`post-thread-user`.`created` AS `created`,
`post-thread-user`.`uid` AS `uid`,
`post-thread-user`.`starred` AS `starred`,
`post-thread-user`.`mention` AS `mention`,
`post-thread`.`network` AS `network`,
`post-thread-user`.`network` AS `network`,
`post-thread-user`.`contact-id` AS `contact-id`,
`ownercontact`.`contact-type` AS `contact-type`
FROM `post-thread`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
FROM `post-thread-user`
INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread`.`owner-id`
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread`.`owner-id`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
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 (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
@ -2042,19 +2153,17 @@ CREATE VIEW `pending-view` AS SELECT
DROP VIEW IF EXISTS `tag-search-view`;
CREATE VIEW `tag-search-view` AS SELECT
`post-tag`.`uri-id` AS `uri-id`,
`item`.`id` AS `iid`,
`item`.`uri` AS `uri`,
`item`.`guid` AS `guid`,
`item`.`uid` AS `uid`,
`item`.`private` AS `private`,
`item`.`wall` AS `wall`,
`item`.`origin` AS `origin`,
`item`.`gravity` AS `gravity`,
`item`.`received` AS `received`,
`post-user`.`uid` AS `uid`,
`post-user`.`id` AS `iid`,
`post-user`.`private` AS `private`,
`post-user`.`wall` AS `wall`,
`post-user`.`origin` AS `origin`,
`post-user`.`gravity` AS `gravity`,
`post-user`.`received` AS `received`,
`tag`.`name` AS `name`
FROM `post-tag`
INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
WHERE `post-tag`.`type` = 1;
--

View file

@ -2262,7 +2262,6 @@ function api_statuses_user_timeline($type)
$condition[0] .= " AND `id` <= ?";
$condition[] = $max_id;
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
$statuses = Post::selectForUser(api_user(), [], $condition, $params);

View file

@ -216,10 +216,10 @@ function events_post(App $a)
exit();
}
$item_id = Event::store($datarray);
$uri_id = Event::store($datarray);
if (!$cid) {
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item_id);
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$uri_id, (int)$uid);
}
DI::baseUrl()->redirect('events');

View file

@ -113,9 +113,9 @@ function item_post(App $a) {
if ($parent_item_id || $thr_parent_uri) {
if ($parent_item_id) {
$parent_item = Post::selectFirst([], ['id' => $parent_item_id]);
$parent_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $parent_item_id]);
} elseif ($thr_parent_uri) {
$parent_item = Post::selectFirst([], ['uri' => $thr_parent_uri, 'uid' => $profile_uid]);
$parent_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['uri' => $thr_parent_uri, 'uid' => $profile_uid]);
}
// if this isn't the top-level parent of the conversation, find it
@ -125,7 +125,7 @@ function item_post(App $a) {
$toplevel_item = $parent_item;
if ($parent_item['gravity'] != GRAVITY_PARENT) {
$toplevel_item = Post::selectFirst([], ['id' => $toplevel_item['parent']]);
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $toplevel_item['parent']]);
}
}
@ -143,7 +143,7 @@ function item_post(App $a) {
$stored = Item::storeForUserByUriId($toplevel_item['uri-id'], local_user());
Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
if ($stored) {
$toplevel_item = Post::selectFirst([], ['id' => $stored]);
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $stored]);
}
}
@ -462,7 +462,7 @@ function item_post(App $a) {
/*
* Next link in any attachment references we find in the post.
*/
$match = false;
$match = [];
/// @todo these lines should be moved to Model/Attach (Once it exists)
if (!$preview && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/", $body, $match)) {
@ -489,6 +489,7 @@ function item_post(App $a) {
// embedded bookmark or attachment in post? set bookmark flag
$data = BBCode::getAttachmentData($body);
$match = [];
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE;
@ -515,7 +516,7 @@ function item_post(App $a) {
}
$attachments = '';
$match = false;
$match = [];
if (preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
foreach ($match[2] as $mtch) {
@ -603,7 +604,6 @@ function item_post(App $a) {
$datarray['postopts'] = $postopts;
$datarray['origin'] = $origin;
$datarray['moderated'] = false;
$datarray['object'] = $object;
/*
@ -651,7 +651,6 @@ function item_post(App $a) {
// doesn't have an ID.
$datarray["id"] = -1;
$datarray["uri-id"] = -1;
$datarray["item_id"] = -1;
$datarray["author-network"] = Protocol::DFRN;
$o = conversation($a, [array_merge($contact_record, $datarray)], 'search', false, true);
@ -782,7 +781,7 @@ function item_post(App $a) {
// When we are doing some forum posting via ! we have to start the notifier manually.
// These kind of posts don't initiate the notifier call in the item class.
if ($only_to_forum) {
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => false], "Notifier", Delivery::POST, $post_id);
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => false], "Notifier", Delivery::POST, (int)$datarray['uri-id'], (int)$datarray['uid']);
}
Logger::info('post_complete');

View file

@ -176,7 +176,9 @@ EOT;
Hook::callAll('post_local_end', $arr);
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post_id);
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $post_id]);
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post['uri-id'], $post['uid']);
exit();
}

View file

@ -104,7 +104,7 @@ class TagCloud
$tag_stmt = DBA::p("SELECT `name`, COUNT(`name`) AS `total` FROM `tag-search-view`
LEFT JOIN `post-view` ON `tag-search-view`.`uri-id` = `post-view`.`uri-id`
WHERE `tag-search-view`.`uid` = ?
AND `post-view`.`visible` AND NOT `post-view`.`deleted` AND NOT `post-view`.`moderated`
AND `post-view`.`visible` AND NOT `post-view`.`deleted`
$sql_options
GROUP BY `name` ORDER BY `total` DESC $limit",
$uid

View file

@ -53,6 +53,12 @@ class System
while ($func = array_pop($trace)) {
if (!empty($func['class'])) {
if (in_array($previous['function'], ['insert', 'fetch', 'toArray', 'exists', 'count', 'selectFirst', 'selectToArray',
'select', 'update', 'delete', 'selectFirstForUser', 'selectForUser'])
&& (substr($previous['class'], 0, 15) === 'Friendica\Model')) {
continue;
}
// Don't show multiple calls from the Database classes to show the essential parts of the callstack
$func['database'] = in_array($func['class'], ['Friendica\Database\DBA', 'Friendica\Database\Database']);
if (!$previous['database'] || !$func['database']) {

View file

@ -1232,7 +1232,7 @@ class DBStructure
} elseif ($verbose) {
echo "Zero permissionset already added\n";
}
if (!self::existsForeignKeyForField('item', 'psid')) {
if (self::existsTable('item') && !self::existsForeignKeyForField('item', 'psid')) {
$sets = DBA::p("SELECT `psid`, `item`.`uid`, `item`.`private` FROM `item`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
WHERE `permissionset`.`id` IS NULL AND NOT `psid` IS NULL");

View file

@ -27,6 +27,7 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\Post\Category;
@ -44,7 +45,7 @@ class PostUpdate
{
// Needed for the helper function to read from the legacy term table
const OBJECT_TYPE_POST = 1;
const VERSION = 1384;
const VERSION = 1400;
/**
* Calls the post update functions
@ -87,7 +88,9 @@ class PostUpdate
if (!self::update1384()) {
return false;
}
if (!self::update1400()) {
return false;
}
return true;
}
@ -179,6 +182,11 @@ class PostUpdate
return true;
}
if (!DBStructure::existsTable('item')) {
DI::config()->set('system', 'post_update_version', 1329);
return true;
}
$id = DI::config()->get('system', 'post_update_version_1329_id', 0);
Logger::info('Start', ['item' => $id]);
@ -514,7 +522,7 @@ class PostUpdate
return true;
}
if (!DBStructure::existsTable('item-activity')) {
if (!DBStructure::existsTable('item-activity') || !DBStructure::existsTable('item')) {
DI::config()->set('system', 'post_update_version', 1347);
return true;
}
@ -761,4 +769,46 @@ class PostUpdate
return false;
}
/**
* update the "hash" field in the photo table
*
* @return bool "true" when the job is done
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
private static function update1400()
{
// Was the script completed?
if (DI::config()->get("system", "post_update_version") >= 1400) {
return true;
}
$condition = ["`extid` != ? AND EXISTS(SELECT `id` FROM `post-user` WHERE `uri-id` = `item`.`uri-id` AND `uid` = `item`.`uid` AND `external-id` IS NULL)", ''];
Logger::info('Start', ['rest' => DBA::count('item', $condition)]);
$rows = 0;
$items = DBA::select('item', ['uri-id', 'uid', 'extid'], $condition, ['order' => ['id'], 'limit' => 10000]);
if (DBA::errorNo() != 0) {
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
return false;
}
while ($item = DBA::fetch($items)) {
Post::update(['external-id' => ItemURI::getIdByURI($item['extid'])], ['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
++$rows;
}
DBA::close($items);
Logger::info('Processed', ['rows' => $rows]);
if ($rows <= 100) {
DI::config()->set("system", "post_update_version", 1400);
Logger::info('Done');
return true;
}
return false;
}
}

View file

@ -61,7 +61,9 @@ class Status extends BaseFactory
*/
public function createFromUriId(int $uriId, $uid = 0)
{
$item = Post::selectFirst([], ['uri-id' => $uriId, 'uid' => $uid]);
$fields = ['uri-id', 'uid', 'author-id', 'starred', 'app', 'title', 'body', 'raw-body', 'created',
'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity'];
$item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => $uid]);
if (!$item) {
throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . 'not found' . ($uid ? ' for user ' . $uid : '.'));
}

View file

@ -1343,7 +1343,7 @@ class Contact
$o .= conversation($a, $items, 'contacts', $update, false, 'commented', local_user());
} else {
$items = Post::toArray(Post::selectForUser(local_user(), [], $condition, $params));
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params));
$o .= conversation($a, $items, 'contact-posts', $update);
}

View file

@ -173,32 +173,32 @@ class Event
{
$ev = [];
$match = '';
$match = [];
if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $text, $match)) {
$ev['summary'] = $match[1];
}
$match = '';
$match = [];
if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is", $text, $match)) {
$ev['desc'] = $match[1];
}
$match = '';
$match = [];
if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is", $text, $match)) {
$ev['start'] = $match[1];
}
$match = '';
$match = [];
if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is", $text, $match)) {
$ev['finish'] = $match[1];
}
$match = '';
$match = [];
if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is", $text, $match)) {
$ev['location'] = $match[1];
}
$match = '';
$match = [];
if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is", $text, $match)) {
$ev['adjust'] = $match[1];
}
@ -330,7 +330,7 @@ class Event
DBA::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
$item = Post::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
$item = Post::selectFirst(['id', 'uri-id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBA::isResult($item)) {
$object = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
$object .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
@ -339,9 +339,9 @@ class Event
$fields = ['body' => self::getBBCode($event), 'object' => $object, 'edited' => $event['edited']];
Item::update($fields, ['id' => $item['id']]);
$item_id = $item['id'];
$uriid = $item['uri-id'];
} else {
$item_id = 0;
$uriid = 0;
}
Hook::callAll('event_updated', $event['id']);
@ -349,7 +349,7 @@ class Event
// New event. Store it.
DBA::insert('event', $event);
$item_id = 0;
$uriid = 0;
// Don't create an item for birthday events
if ($event['type'] == 'event') {
@ -360,6 +360,7 @@ class Event
$item_arr['uid'] = $event['uid'];
$item_arr['contact-id'] = $event['cid'];
$item_arr['uri'] = $event['uri'];
$item_arr['uri-id'] = ItemURI::getIdByURI($event['uri']);
$item_arr['guid'] = $event['guid'];
$item_arr['plink'] = $arr['plink'] ?? '';
$item_arr['post-type'] = Item::PT_EVENT;
@ -392,13 +393,15 @@ class Event
$item_arr['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
$item_arr['object'] .= '</object>' . "\n";
$item_id = Item::insert($item_arr);
if (Item::insert($item_arr)) {
$uriid = $item_arr['uri-id'];
}
}
Hook::callAll("event_created", $event['id']);
}
return $item_id;
return $uriid;
}
/**

View file

@ -77,13 +77,13 @@ class Item
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
'wall', 'private', 'starred', 'origin', 'title', 'body', 'language',
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'item_id',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network',
'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type',
'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar',
'writable', 'self', 'cid', 'alias',
'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish',
'event-created', 'event-edited', 'event-start', 'event-finish',
'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-adjust', 'event-ignore', 'event-id',
'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed'
@ -91,34 +91,38 @@ class Item
// Field list that is used to deliver items via the protocols
const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid',
'parent-guid', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
'private', 'title', 'body', 'location', 'coord', 'app',
'deleted', 'extid', 'post-type', 'gravity',
'parent-guid', 'received', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
'private', 'title', 'body', 'raw-body', 'location', 'coord', 'app',
'inform', 'deleted', 'extid', 'post-type', 'gravity',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'author-id', 'author-link', 'owner-link', 'contact-uid',
'signed_text', 'network'];
'author-id', 'author-link', 'owner-id', 'owner-link', 'contact-uid',
'signed_text', 'network', 'wall', 'contact-id', 'plink', 'forum_mode', 'origin',
'thr-parent-id', 'parent-uri-id', 'postopts', 'pubmail',
'event-created', 'event-edited', 'event-start', 'event-finish',
'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-adjust', 'event-ignore', 'event-id'];
// All fields in the item table
const ITEM_FIELDLIST = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent',
'guid', 'uri-id', 'parent-uri-id', 'thr-parent-id', 'vid',
'contact-id', 'type', 'wall', 'gravity', 'extid', 'psid',
'contact-id', 'wall', 'gravity', 'extid', 'psid',
'created', 'edited', 'commented', 'received', 'changed', 'verb',
'postopts', 'plink', 'resource-id', 'event-id', 'inform',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type',
'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
'private', 'pubmail', 'visible', 'starred',
'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network',
'title', 'content-warning', 'body', 'location', 'coord', 'app',
'rendered-hash', 'rendered-html', 'object-type', 'object', 'target-type', 'target',
'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'causer-id'];
// Item fiels that still are in use
// Item fields that still are in use
const USED_FIELDLIST = ['id', 'parent', 'guid', 'uri', 'uri-id', 'parent-uri', 'parent-uri-id',
'thr-parent', 'thr-parent-id', 'created', 'edited', 'commented', 'received', 'changed',
'gravity', 'network', 'owner-id', 'author-id', 'causer-id', 'vid', 'extid', 'post-type',
'global', 'private', 'visible', 'moderated', 'deleted', 'uid', 'contact-id',
'global', 'private', 'visible', 'deleted', 'uid', 'contact-id',
'wall', 'origin', 'pubmail', 'starred', 'unseen', 'mention', 'forum_mode', 'psid',
'event-id', 'type', 'bookmark'];
'event-id'];
// Legacy item fields that aren't stored any more in the item table
const LEGACY_FIELDLIST = ['uri-hash', 'iaid', 'icid', 'attach',
@ -208,7 +212,8 @@ class Item
DBA::close($items);
foreach ($notify_items as $notify_item) {
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $notify_item);
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $notify_item]);
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
}
return $rows;
@ -350,7 +355,7 @@ class Item
// send the notification upstream/downstream
if ($priority) {
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, intval($item['id']));
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, (int)$item['uri-id'], (int)$item['uid']);
}
} elseif ($item['uid'] != 0) {
Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]);
@ -955,6 +960,10 @@ class Item
$item['deny_gid']
);
if (!empty($item['extid'])) {
$item['external-id'] = ItemURI::getIdByURI($item['extid']);
}
if ($item['verb'] == Activity::ANNOUNCE) {
self::setOwnerforResharedItem($item);
}
@ -980,6 +989,12 @@ class Item
Post\Media::insertFromAttachment($item['uri-id'], $item['attach']);
}
if (empty($item['event-id'])) {
unset($item['event-id']);
}
Post::insert($item['uri-id'], $item);
if ($item['gravity'] == GRAVITY_PARENT) {
Post\Thread::insert($item['uri-id'], $item);
}
@ -1010,128 +1025,101 @@ class Item
Tag::storeFromBody($item['uri-id'], $item['body']);
}
$id = Post\User::insert($item['uri-id'], $item['uid'], $item);
if (!$id) {
Logger::notice('Post-User is already inserted - aborting', ['uid' => $item['uid'], 'uri-id' => $item['uri-id']]);
return 0;
}
if ($item['gravity'] == GRAVITY_PARENT) {
$item['post-user-id'] = $id;
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
}
$condition = ['uri-id' => $item['uri-id'], 'uid' => $item['uid'], 'network' => $item['network']];
$condition = ['uri-id' => $item['uri-id'], 'uid' => $item['uid']];
if (Post::exists($condition)) {
Logger::notice('Item is already inserted - aborting', $condition);
return 0;
}
// Remove all fields that aren't part of the item table
$table_fields = DBStructure::getFieldsForTable('item', $item);
// We remove all legacy fields that now are stored in other tables
foreach (self::LEGACY_FIELDLIST as $field) {
unset($table_fields[$field]);
$post_user_id = Post\User::insert($item['uri-id'], $item['uid'], $item);
if (!$post_user_id) {
Logger::notice('Post-User is already inserted - aborting', ['uid' => $item['uid'], 'uri-id' => $item['uri-id']]);
return 0;
}
$result = DBA::insert('item', $table_fields);
if ($item['gravity'] == GRAVITY_PARENT) {
$item['post-user-id'] = $post_user_id;
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
}
// When the item was successfully stored we fetch the ID of the item.
$current_post = DBA::lastInsertId();
Logger::notice('created item', ['post-id' => $post_user_id, 'uid' => $item['uid'], 'network' => $item['network'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
if (empty($current_post) || !DBA::isResult($result)) {
$posted_item = Post::selectFirst(self::ITEM_FIELDLIST, ['post-user-id' => $post_user_id]);
if (!DBA::isResult($posted_item)) {
// On failure store the data into a spool file so that the "SpoolPost" worker can try again later.
Logger::warning('Could not store item. it will be spooled', ['result' => $result, 'id' => $current_post]);
Logger::warning('Could not store item. it will be spooled', ['id' => $post_user_id]);
self::spool($orig_item);
return 0;
}
Logger::notice('created item', ['id' => $current_post, 'uid' => $item['uid'], 'network' => $item['network'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
if (!$parent_id || ($item['gravity'] === GRAVITY_PARENT)) {
$parent_id = $current_post;
}
// Set parent id
DBA::update('item', ['parent' => $parent_id], ['id' => $current_post]);
$item['id'] = $current_post;
$item['parent'] = $parent_id;
// update the commented timestamp on the parent
if (DI::config()->get('system', 'like_no_comment')) {
// Update when it is a comment
$update_commented = in_array($item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]);
$update_commented = in_array($posted_item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]);
} else {
// Update when it isn't a follow or tag verb
$update_commented = !in_array($item['verb'], [Activity::FOLLOW, Activity::TAG]);
$update_commented = !in_array($posted_item['verb'], [Activity::FOLLOW, Activity::TAG]);
}
if ($update_commented) {
Post::update(['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
$fields = ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
} else {
Post::update(['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
$fields = ['changed' => DateTimeFormat::utcNow()];
}
Post::update($fields, ['uri-id' => $posted_item['parent-uri-id'], 'uid' => $posted_item['uid']]);
// In that function we check if this is a forum post. Additionally we delete the item under certain circumstances
if (self::tagDeliver($item['uid'], $current_post)) {
if (self::tagDeliver($posted_item['uid'], $post_user_id)) {
// Get the user information for the logging
$user = User::getById($uid);
Logger::notice('Item had been deleted', ['id' => $current_post, 'user' => $uid, 'account-type' => $user['account-type']]);
Logger::notice('Item had been deleted', ['id' => $post_user_id, 'user' => $uid, 'account-type' => $user['account-type']]);
return 0;
}
if (!$dontcache) {
$posted_item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $current_post]);
if (DBA::isResult($posted_item)) {
if ($notify) {
Hook::callAll('post_local_end', $posted_item);
} else {
Hook::callAll('post_remote_end', $posted_item);
}
if ($notify) {
Hook::callAll('post_local_end', $posted_item);
} else {
Logger::log('new item not found in DB, id ' . $current_post);
}
Hook::callAll('post_remote_end', $posted_item);
}
}
if ($item['gravity'] === GRAVITY_PARENT) {
self::addShadow($current_post);
if ($posted_item['gravity'] === GRAVITY_PARENT) {
self::addShadow($post_user_id);
} else {
self::addShadowPost($current_post);
self::addShadowPost($post_user_id);
}
self::updateContact($item);
self::updateContact($posted_item);
Post\UserNotification::setNotification($item['uri-id'], $item['uid']);
Post\UserNotification::setNotification($posted_item['uri-id'], $posted_item['uid']);
check_user_notification($item['uri-id'], $item['uid']);
//check_user_notification($current_post);
check_user_notification($posted_item['uri-id'], $posted_item['uid']);
// Distribute items to users who subscribed to their tags
self::distributeByTags($item);
self::distributeByTags($posted_item);
// Automatically reshare the item if the "remote_self" option is selected
self::autoReshare($item);
self::autoReshare($posted_item);
$transmit = $notify || ($item['visible'] && ($parent_origin || $item['origin']));
$transmit = $notify || ($posted_item['visible'] && ($parent_origin || $posted_item['origin']));
if ($transmit) {
$transmit_item = Post::selectFirst(['verb', 'origin'], ['id' => $item['id']]);
// Don't relay participation messages
if (($transmit_item['verb'] == Activity::FOLLOW) &&
(!$transmit_item['origin'] || ($item['author-id'] != Contact::getPublicIdByUserId($uid)))) {
Logger::info('Participation messages will not be relayed', ['item' => $item['id'], 'uri' => $item['uri'], 'verb' => $transmit_item['verb']]);
if (($posted_item['verb'] == Activity::FOLLOW) &&
(!$posted_item['origin'] || ($posted_item['author-id'] != Contact::getPublicIdByUserId($uid)))) {
Logger::info('Participation messages will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'verb' => $posted_item['verb']]);
$transmit = false;
}
}
if ($transmit) {
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post);
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, (int)$posted_item['uri-id'], (int)$posted_item['uid']);
}
return $current_post;
return $post_user_id;
}
/**
@ -1153,7 +1141,7 @@ class Item
return;
}
$author = Contact::selectFirst(['url', 'contact-type'], ['id' => $item['author-id']]);
$author = Contact::selectFirst(['url', 'contact-type', 'network'], ['id' => $item['author-id']]);
if (!DBA::isResult($author)) {
Logger::error('Author not found', ['id' => $item['author-id']]);
return;
@ -1161,7 +1149,7 @@ class Item
$cid = Contact::getIdForURL($author['url'], $item['uid']);
if (empty($cid) || !Contact::isSharing($cid, $item['uid'])) {
Logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid']]);
Logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid'], 'cid' => $cid]);
return;
}
@ -1220,15 +1208,17 @@ class Item
$condition = ["`id` IN (SELECT `parent` FROM `post-view` WHERE `id` = ?)", $itemid];
$parent = Post::selectFirst(['owner-id'], $condition);
if (!DBA::isResult($parent)) {
Logger::warning('Item not found', ['condition' => $condition]);
return;
}
// Only distribute public items from native networks
$condition = ['id' => $itemid, 'uid' => 0,
'network' => array_merge(Protocol::FEDERATED ,['']),
'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => [self::PUBLIC, self::UNLISTED]];
'visible' => true, 'deleted' => false, 'private' => [self::PUBLIC, self::UNLISTED]];
$item = Post::selectFirst(self::ITEM_FIELDLIST, $condition);
if (!DBA::isResult($item)) {
Logger::warning('Item not found', ['condition' => $condition]);
return;
}
@ -1405,8 +1395,8 @@ class Item
*/
private static function addShadow($itemid)
{
$fields = ['uid', 'private', 'moderated', 'visible', 'deleted', 'network', 'uri-id'];
$condition = ['id' => $itemid, 'parent' => [0, $itemid]];
$fields = ['uid', 'private', 'visible', 'deleted', 'network', 'uri-id'];
$condition = ['id' => $itemid, 'gravity' => GRAVITY_PARENT];
$item = Post::selectFirst($fields, $condition);
if (!DBA::isResult($item)) {
@ -1419,7 +1409,7 @@ class Item
}
// Is it a visible public post?
if (!$item["visible"] || $item["deleted"] || $item["moderated"] || ($item["private"] == self::PRIVATE)) {
if (!$item["visible"] || $item["deleted"] || ($item["private"] == self::PRIVATE)) {
return;
}
@ -1801,8 +1791,7 @@ class Item
if (!$mention) {
if (($community_page || $prvgroup) &&
!$item['wall'] && !$item['origin'] && ($item['gravity'] == GRAVITY_PARENT)) {
Logger::info('Delete private group/communiy top-level item without mention', ['id' => $item_id, 'guid'=> $item['guid']]);
DBA::delete('item', ['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
Logger::info('Delete private group/communiy top-level item without mention', ['id' => $item['id'], 'guid'=> $item['guid']]);
Post\User::delete(['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
return true;
}
@ -1850,11 +1839,11 @@ class Item
$fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode, 'contact-id' => $self['id'],
'owner-id' => $owner_id, 'private' => $private, 'psid' => $psid];
self::update($fields, ['id' => $item_id]);
self::update($fields, ['id' => $item['id']]);
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', Delivery::POST, $item_id);
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', Delivery::POST, (int)$item['uri-id'], (int)$item['uid']);
self::performActivity($item_id, 'announce', $uid);
self::performActivity($item['id'], 'announce', $uid);
return false;
}
@ -2154,7 +2143,7 @@ class Item
$condition[0] .= " AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY";
$condition[] = $days;
$items = Post::select(['resource-id', 'starred', 'type', 'id', 'post-type', 'uid', 'uri-id'], $condition);
$items = Post::select(['resource-id', 'starred', 'id', 'post-type', 'uid', 'uri-id'], $condition);
if (!DBA::isResult($items)) {
return;
@ -2187,9 +2176,9 @@ class Item
continue;
} elseif (!$expire_starred && intval($item['starred'])) {
continue;
} elseif (!$expire_notes && (($item['type'] == 'note') || ($item['post-type'] == self::PT_PERSONAL_NOTE))) {
} elseif (!$expire_notes && ($item['post-type'] == self::PT_PERSONAL_NOTE)) {
continue;
} elseif (!$expire_items && ($item['type'] != 'note') && ($item['post-type'] != self::PT_PERSONAL_NOTE)) {
} elseif (!$expire_items && ($item['post-type'] != self::PT_PERSONAL_NOTE)) {
continue;
}
@ -2203,7 +2192,7 @@ class Item
public static function firstPostDate($uid, $wall = false)
{
$condition = ['gravity' => GRAVITY_PARENT, 'uid' => $uid, 'wall' => $wall, 'deleted' => false, 'visible' => true, 'moderated' => false];
$condition = ['gravity' => GRAVITY_PARENT, 'uid' => $uid, 'wall' => $wall, 'deleted' => false, 'visible' => true];
$params = ['order' => ['received' => false]];
$thread = Post::selectFirst(['received'], $condition, $params);
if (DBA::isResult($thread)) {

View file

@ -21,13 +21,41 @@
namespace Friendica\Model;
use BadMethodCallException;
use Friendica\Core\Logger;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\Protocol\Activity;
class Post
{
/**
* Insert a new post entry
*
* @param integer $uri_id
* @param array $fields
* @return int ID of inserted post
* @throws \Exception
*/
public static function insert(int $uri_id, array $data = [])
{
if (empty($uri_id)) {
throw new BadMethodCallException('Empty URI_id');
}
$fields = DBStructure::getFieldsForTable('post', $data);
// Additionally assign the key fields
$fields['uri-id'] = $uri_id;
if (!DBA::insert('post', $fields, Database::INSERT_IGNORE)) {
return 0;
}
return DBA::lastInsertId();
}
/**
* Fetch a single post row
*
@ -65,6 +93,10 @@ class Post
}
}
if (array_key_exists('extid', $row) && is_null($row['extid'])) {
$row['extid'] = '';
}
return $row;
}
@ -189,12 +221,9 @@ class Post
private static function selectView(string $view, array $selected = [], array $condition = [], $params = [])
{
if (empty($selected)) {
$selected = array_merge(['author-addr', 'author-nick', 'owner-addr', 'owner-nick', 'causer-addr', 'causer-nick',
'causer-network', 'photo', 'name-date', 'uri-date', 'avatar-date', 'thumb', 'dfrn-id',
'parent-guid', 'parent-network', 'parent-author-id', 'parent-author-link', 'parent-author-name',
'parent-author-network', 'signed_text', 'language', 'raw-body'], Item::DISPLAY_FIELDLIST, Item::ITEM_FIELDLIST);
if ($view != 'post-view') {
$selected = array_merge(Item::DISPLAY_FIELDLIST, Item::ITEM_FIELDLIST);
if ($view == 'post-thread-view') {
$selected = array_merge($selected, ['ignored', 'iid']);
}
}
@ -253,7 +282,7 @@ class Post
}
$condition = DBA::mergeConditions($condition,
["`visible` AND NOT `deleted` AND NOT `moderated`
["`visible` AND NOT `deleted`
AND NOT `author-blocked` AND NOT `owner-blocked`
AND (NOT `causer-blocked` OR `causer-id` = ?) AND NOT `contact-blocked`
AND ((NOT `contact-readonly` AND NOT `contact-pending` AND (`contact-rel` IN (?, ?)))
@ -434,6 +463,20 @@ class Post
$affected = max($affected, DBA::affectedRows());
}
$update_fields = DBStructure::getFieldsForTable('post', $fields);
if (!empty($update_fields)) {
if (empty($uriids)) {
$rows = DBA::selectToArray('post-view', ['uri-id'], $condition, ['group_by' => ['uri-id']]);
$uriids = array_column($rows, 'uri-id');
}
if (!DBA::update('post', $update_fields, ['uri-id' => $uriids])) {
DBA::rollback();
Logger::notice('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]);
return false;
}
$affected = max($affected, DBA::affectedRows());
}
$update_fields = Post\DeliveryData::extractFields($fields);
if (!empty($update_fields)) {
if (empty($uriids)) {
@ -450,7 +493,7 @@ class Post
$update_fields = DBStructure::getFieldsForTable('post-thread', $fields);
if (!empty($update_fields)) {
$rows = DBA::selectToArray('post-view', ['uri-id'], $condition, ['group_by' => ['uri-id']]);
$rows = DBA::selectToArray('post-view', ['uri-id'], $thread_condition, ['group_by' => ['uri-id']]);
$uriids = array_column($rows, 'uri-id');
if (!DBA::update('post-thread', $update_fields, ['uri-id' => $uriids])) {
DBA::rollback();
@ -472,26 +515,25 @@ class Post
$affected = max($affected, DBA::affectedRows());
}
$update_fields = [];
foreach (Item::USED_FIELDLIST as $field) {
if (array_key_exists($field, $fields)) {
$update_fields[$field] = $fields[$field];
}
}
if (!empty($update_fields)) {
$rows = DBA::selectToArray('post-view', ['id'], $condition, []);
$ids = array_column($rows, 'id');
if (!DBA::update('item', $update_fields, ['id' => $ids])) {
DBA::rollback();
Logger::notice('Updating item failed', ['fields' => $update_fields, 'condition' => $condition]);
return false;
}
$affected = max($affected, DBA::affectedRows());
}
DBA::commit();
Logger::info('Updated posts', ['rows' => $affected]);
return $affected;
}
/**
* Delete a row from the post table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
{
return DBA::delete('post', $conditions, $options);
}
}

View file

@ -434,7 +434,7 @@ class Network extends BaseModule
}
if (DBA::isResult($items)) {
$parents = array_column($items, 'parent');
$parents = array_column($items, 'parent-uri-id');
} else {
$parents = [];
}
@ -446,7 +446,7 @@ class Network extends BaseModule
$condition = ['unseen' => true, 'uid' => local_user()];
self::setItemsSeenByCondition($condition);
} elseif (!empty($parents)) {
$condition = ['unseen' => true, 'uid' => local_user(), 'parent' => $parents];
$condition = ['unseen' => true, 'uid' => local_user(), 'parent-uri-id' => $parents];
self::setItemsSeenByCondition($condition);
}

View file

@ -189,7 +189,7 @@ class Status extends BaseProfile
0, $a->profile['uid']]);
$condition = DBA::mergeConditions($condition, ['uid' => $a->profile['uid'], 'network' => Protocol::FEDERATED,
'visible' => true, 'deleted' => false, 'moderated' => false]);
'visible' => true, 'deleted' => false]);
$pager = new Pager(DI::l10n(), $args->getQueryString(), $itemspage_network);
$params = ['limit' => [$pager->getStart(), $pager->getItemsPerPage()], 'order' => ['received' => true]];

View file

@ -9,6 +9,7 @@ use Friendica\Content\Widget;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Post\Category;
use Friendica\Module\BaseSearch;
@ -69,7 +70,7 @@ class Filed extends BaseSearch
$item_condition = ['uid' => local_user(), 'uri-id' => $posts];
$item_params = ['order' => ['uri-id' => true]];
$items = Post::toArray(Post::selectForUser(local_user(), [], $item_condition, $item_params));
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
$o .= conversation(DI::app(), $items, 'filed', false, false, '', local_user());

View file

@ -172,7 +172,7 @@ class Index extends BaseSearch
if (!empty($uriids)) {
$params = ['order' => ['id' => true], 'group_by' => ['uri-id']];
$items = Post::toArray(Post::selectForUser(local_user(), [], ['uri-id' => $uriids], $params));
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, ['uri-id' => $uriids], $params));
}
if (empty($items)) {

View file

@ -81,7 +81,7 @@ class Profile extends BaseModule
"SELECT DISTINCT(`parent-uri-id`) AS `uri-id`, `created` FROM `post-view`
WHERE `uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending`
AND `visible` AND (NOT `deleted` OR `gravity` = ?)
AND NOT `moderated` AND `wall` $sql_extra4 $sql_extra
AND `wall` $sql_extra4 $sql_extra
ORDER BY `received` DESC",
$a->profile['uid'],
GRAVITY_ACTIVITY

View file

@ -868,8 +868,9 @@ class Processor
}
$replyto = JsonLD::fetchElement($activity['as:object'], 'as:inReplyTo', '@id');
if (Post::exists(['uri' => $replyto])) {
Logger::info('Post is a reply to an existing post - accepted', ['id' => $id, 'replyto' => $replyto]);
$uriid = ItemURI::getIdByURI($replyto);
if (Post::exists(['uri-id' => $uriid])) {
Logger::info('Post is a reply to an existing post - accepted', ['id' => $id, 'uri-id' => $uriid, 'replyto' => $replyto]);
return true;
}

View file

@ -930,7 +930,7 @@ class Receiver
} else {
Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', Logger::DEBUG);
$item = Post::selectFirst([], ['uri' => $object_id]);
$item = Post::selectFirst(Item::DELIVER_FIELDLIST, ['uri' => $object_id]);
if (!DBA::isResult($item)) {
Logger::log('Object with url ' . $object_id . ' was not found locally.', Logger::DEBUG);
return false;

View file

@ -258,7 +258,7 @@ class Transmitter
$condition = array_merge($condition,
['author-id' => $public_contact,
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
'deleted' => false, 'visible' => true, 'moderated' => false]);
'deleted' => false, 'visible' => true]);
$count = Post::count($condition);
@ -1045,19 +1045,19 @@ class Transmitter
public static function createActivityFromItem(int $item_id, bool $object_mode = false)
{
Logger::info('Fetching activity', ['item' => $item_id]);
$item = Post::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
$item = Post::selectFirst(Item::DELIVER_FIELDLIST, ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
if (!DBA::isResult($item)) {
return false;
}
// In case of a forum post ensure to return the original post if author and forum are on the same machine
if (!empty($item['forum_mode'])) {
if (($item['gravity'] == GRAVITY_PARENT) && !empty($item['forum_mode'])) {
$author = Contact::getById($item['author-id'], ['nurl']);
if (!empty($author['nurl'])) {
$self = Contact::selectFirst(['uid'], ['nurl' => $author['nurl'], 'self' => true]);
if (!empty($self['uid'])) {
$forum_item = Post::selectFirst([], ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
if (DBA::isResult($item)) {
$forum_item = Post::selectFirst(Item::DELIVER_FIELDLIST, ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
if (DBA::isResult($forum_item)) {
$item = $forum_item;
}
}
@ -1645,7 +1645,7 @@ class Transmitter
return [];
}
$reshared_item = Post::selectFirst([], ['guid' => $reshared['guid']]);
$reshared_item = Post::selectFirst(Item::DELIVER_FIELDLIST, ['guid' => $reshared['guid']]);
if (!DBA::isResult($reshared_item)) {
return [];
}

View file

@ -887,9 +887,9 @@ class Feed
$params = ['order' => ['received' => true], 'limit' => $max_items];
if ($filter === 'posts') {
$ret = Post::selectThread([], $condition, $params);
$ret = Post::selectThread(Item::DELIVER_FIELDLIST, $condition, $params);
} else {
$ret = Post::select([], $condition, $params);
$ret = Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
}
$items = Post::toArray($ret);
@ -1041,7 +1041,7 @@ class Feed
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => [Item::PUBLIC, Item::UNLISTED],
'network' => Protocol::FEDERATED];
$repeated_item = Post::selectFirst([], $condition);
$repeated_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition);
if (!DBA::isResult($repeated_item)) {
return false;
}

View file

@ -25,7 +25,6 @@ use Friendica\Core\Logger;
use Friendica\Core\Worker;
use Friendica\Model\Contact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature;
@ -40,10 +39,11 @@ class APDelivery
* @param string $inbox The URL of the recipient profile
* @param integer $uid The ID of the user who triggered this delivery
* @param array $receivers The contact IDs related to the inbox URL for contact archival housekeeping
* @param int $uri_id URI-ID of item to be transmitted
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function execute(string $cmd, int $item_id, string $inbox, int $uid, array $receivers = [])
public static function execute(string $cmd, int $item_id, string $inbox, int $uid, array $receivers = [], int $uri_id = 0)
{
if (ActivityPub\Transmitter::archivedInbox($inbox)) {
Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uid' => $uid]);
@ -54,7 +54,20 @@ class APDelivery
return;
}
Logger::info('Invoked', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uid' => $uid]);
if (empty($uri_id) && !empty($item_id)) {
$item = Post::selectFirst(['uri-id', 'id'], ['item-id' => $item_id]);
if (!empty($item['uri-id'])) {
$uri_id = $item['uri-id'];
$item_id = $item['id'];
}
} elseif (!empty($uri_id) && !empty($item_id)) {
$item = Post::selectFirst(['id'], ['uri-id' => $uri_id, 'uid' => $uid]);
if (!empty($item['uri-id'])) {
$item_id = $item['id'];
}
}
Logger::info('Invoked', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid]);
$success = true;
@ -81,8 +94,6 @@ class APDelivery
}
// This should never fail and is temporariy (until the move to the "post" structure)
$item = Post::selectFirst(['uri-id'], ['id' => $item_id]);
$uriid = $item['uri-id'] ?? 0;
$gsid = null;
foreach ($receivers as $receiver) {
@ -105,9 +116,9 @@ class APDelivery
}
if (!$success && !Worker::defer() && in_array($cmd, [Delivery::POST])) {
Post\DeliveryData::incrementQueueFailed($uriid);
Post\DeliveryData::incrementQueueFailed($uri_id);
} elseif ($success && in_array($cmd, [Delivery::POST])) {
Post\DeliveryData::incrementQueueDone($uriid, Post\DeliveryData::ACTIVITYPUB);
Post\DeliveryData::incrementQueueDone($uri_id, Post\DeliveryData::ACTIVITYPUB);
}
}
}

View file

@ -42,9 +42,10 @@ class CleanItemUri
}
Logger::notice('Start deleting orphaned URI-ID', ['last-id' => $item['uri-id']]);
$ret = DBA::e("DELETE FROM `item-uri` WHERE `id` < ?
AND NOT `id` IN (SELECT `uri-id` FROM `item`)
AND NOT `id` IN (SELECT `parent-uri-id` FROM `item`)
AND NOT `id` IN (SELECT `thr-parent-id` FROM `item`)", $item['uri-id']);
AND NOT EXISTS(SELECT `uri-id` FROM `post-user` WHERE `uri-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `parent-uri-id` FROM `post-user` WHERE `parent-uri-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `thr-parent-id` FROM `post-user` WHERE `thr-parent-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `external-id` FROM `post-user` WHERE `external-id` = `item-uri`.`id`)", $item['uri-id']);
Logger::notice('Orphaned URI-ID entries removed', ['result' => $ret, 'rows' => DBA::affectedRows()]);
}
}

View file

@ -111,9 +111,6 @@ class Cron
// update nodeinfo data
Worker::add(PRIORITY_LOW, 'NodeInfo');
// Repair entries in the database
Worker::add(PRIORITY_LOW, 'RepairDatabase');
Worker::add(PRIORITY_LOW, 'Expire');
Worker::add(PRIORITY_LOW, 'ExpirePosts');

View file

@ -35,6 +35,8 @@ use Friendica\Util\Network;
use Friendica\Core\Worker;
use Friendica\Model\Conversation;
use Friendica\Model\FContact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Protocol\Relay;
class Delivery
@ -49,9 +51,27 @@ class Delivery
const REMOVAL = 'removeme';
const PROFILEUPDATE = 'profileupdate';
public static function execute($cmd, $target_id, $contact_id)
public static function execute(string $cmd, int $post_uriid, int $contact_id, int $sender_uid = 0)
{
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $target_id, 'contact' => $contact_id]);
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid, 'contact' => $contact_id]);
$target_id = $post_uriid;
if (!empty($sender_uid)) {
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
if (!DBA::isResult($post)) {
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
return;
}
$target_id = $post['id'];
} elseif (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
$post = Post::selectFirst(['id', 'uid', 'uri-id'], ['item-id' => $post_uriid]);
if (DBA::isResult($post)) {
$target_id = $post['id'];
$sender_uid = $post['uid'];
$post_uriid = $post['uri-id'];
}
}
$top_level = false;
$followup = false;
@ -80,9 +100,9 @@ class Delivery
}
$parent_id = intval($item['parent']);
$condition = ['id' => [$target_id, $parent_id], 'visible' => true, 'moderated' => false];
$condition = ['id' => [$target_id, $parent_id], 'visible' => true];
$params = ['order' => ['id']];
$itemdata = Model\Post::select([], $condition, $params);
$itemdata = Model\Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
while ($item = Model\Post::fetch($itemdata)) {
if ($item['verb'] == Activity::ANNOUNCE) {

View file

@ -25,6 +25,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
@ -44,10 +45,12 @@ class Expire
Logger::log('Delete expired items', Logger::DEBUG);
// physically remove anything that has been deleted for more than two months
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
$rows = Post::select(['id', 'guid', 'uri-id', 'uid'], $condition);
$rows = Post::select(['item-id', 'guid', 'uri-id', 'uid'], $condition);
while ($row = Post::fetch($rows)) {
Logger::info('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]);
DBA::delete('item', ['id' => $row['id']]);
Logger::info('Delete expired item', ['id' => $row['item-id'], 'guid' => $row['guid']]);
if (DBStructure::existsTable('item')) {
DBA::delete('item', ['id' => $row['item-id']]);
}
Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
Post\ThreadUser::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
}
@ -55,21 +58,16 @@ class Expire
Logger::info('Deleting orphaned post-content - start');
/// @todo Replace "item with "post-user" in the future when "item" is removed
$condition = ["NOT EXISTS (SELECT `uri-id` FROM `item` WHERE `item`.`uri-id` = `post-content`.`uri-id`)"];
$condition = ["NOT EXISTS (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uri-id` = `post-content`.`uri-id`)"];
DBA::delete('post-content', $condition);
Logger::info('Orphaned post-content deleted', ['rows' => DBA::affectedRows()]);
Logger::info('Deleting orphaned post-thread - start');
/// @todo Replace "item with "post-user" in the future when "item" is removed
$condition = ["NOT EXISTS (SELECT `uri-id` FROM `item` WHERE `item`.`uri-id` = `post-thread`.`uri-id`)"];
$condition = ["NOT EXISTS (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uri-id` = `post-thread`.`uri-id`)"];
DBA::delete('post-thread', $condition);
Logger::info('Orphaned item content deleted', ['rows' => DBA::affectedRows()]);
// make this optional as it could have a performance impact on large sites
if (intval(DI::config()->get('system', 'optimize_items'))) {
DBA::e("OPTIMIZE TABLE `item`");
}
Logger::log('Delete expired items - done', Logger::DEBUG);
return;
} elseif (intval($param) > 0) {

View file

@ -22,6 +22,7 @@
namespace Friendica\Worker;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\Model\Photo;
use Friendica\Model\User;
@ -64,7 +65,9 @@ class ExpireAndRemoveUsers
// It seems that sometimes the system wants to delete the records in the wrong order.
// So when the permissionset is deleted and these tables are still filled then an error is thrown.
// So we now delete them before all other user related entries are deleted.
DBA::delete('item', ['uid' => $user['uid']]);
if (DBStructure::existsTable('item')) {
DBA::delete('item', ['uid' => $user['uid']]);
}
DBA::delete('post-user', ['uid' => $user['uid']]);
DBA::delete('profile_field', ['uid' => $user['uid']]);

View file

@ -50,15 +50,18 @@ class ExpirePosts
Logger::notice('Start deleting expired threads', ['expiry_days' => $expire_days]);
$ret = DBA::e("DELETE FROM `item-uri` WHERE `id` IN
(SELECT `uri-id` FROM `post-thread` WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-thread-user` WHERE (`mention` OR `starred` OR `wall` OR `pinned`) AND `uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin` AND `uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-category` WHERE `uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `contact-id` AND `notify_new_posts`
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-thread-user`
WHERE (`mention` OR `starred` OR `wall` OR `pinned`) AND `uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-category`
WHERE `uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-media`
WHERE `uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `post-user` INNER JOIN `contact` ON `contact`.`id` = `contact-id` AND `notify_new_posts`
WHERE `parent-uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item`
WHERE (`origin` OR `starred` OR `resource-id` != 0 OR `event-id` != 0 OR `wall` OR `attach` != '' OR `post-type` = ?)
AND `parent-uri-id` = `post-thread`.`uri-id`))
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `post-user`
WHERE (`origin` OR `event-id` != 0 OR `post-type` = ?) AND `parent-uri-id` = `post-thread`.`uri-id`)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-content`
WHERE `resource-id` != 0 AND `uri-id` = `post-thread`.`uri-id`))
ORDER BY `id` LIMIT ?", $expire_days, Item::PT_PERSONAL_NOTE, $limit);
$rows = DBA::affectedRows();
@ -75,11 +78,11 @@ class ExpirePosts
do {
Logger::notice('Start deleting unclaimed public items', ['expiry_days' => $expire_days_unclaimed]);
$ret = DBA::e("DELETE FROM `item-uri` WHERE `id` IN
(SELECT `uri-id` FROM `item` WHERE `gravity` = ? AND `uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` AS `i` WHERE `i`.`uid` != ?
AND `i`.`parent-uri-id` = `item`.`uri-id`)
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` AS `i` WHERE `i`.`uid` = ?
AND `i`.`parent-uri-id` = `item`.`uri-id` AND `i`.`received` > UTC_TIMESTAMP() - INTERVAL ? DAY))
(SELECT `uri-id` FROM `post-user` WHERE `gravity` = ? AND `uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `post-user` AS `i` WHERE `i`.`uid` != ?
AND `i`.`parent-uri-id` = `post-user`.`uri-id`)
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `post-user` AS `i` WHERE `i`.`uid` = ?
AND `i`.`parent-uri-id` = `post-user`.`uri-id` AND `i`.`received` > UTC_TIMESTAMP() - INTERVAL ? DAY))
ORDER BY `id` LIMIT ?",
GRAVITY_PARENT, 0, $expire_days_unclaimed, 0, 0, $expire_days_unclaimed, $limit);

View file

@ -53,11 +53,29 @@ use Friendica\Protocol\Salmon;
class Notifier
{
public static function execute(string $cmd, int $target_id)
public static function execute(string $cmd, int $post_uriid, int $sender_uid = 0)
{
$a = DI::app();
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $target_id]);
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]);
$target_id = $post_uriid;
if (!empty($sender_uid)) {
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
if (!DBA::isResult($post)) {
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
return;
}
$target_id = $post['id'];
} elseif (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
$post = Post::selectFirst(['id', 'uid', 'uri-id'], ['item-id' => $post_uriid]);
if (DBA::isResult($post)) {
$target_id = $post['id'];
$sender_uid = $post['uid'];
$post_uriid = $post['uri-id'];
}
}
$top_level = false;
$recipients = [];
@ -85,7 +103,7 @@ class Notifier
$ap_contacts = array_merge($ap_contacts, $receivers);
Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'target' => $target_id, 'inbox' => $inbox]);
Worker::add(['priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true],
'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers);
'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid);
}
} elseif ($cmd == Delivery::SUGGESTION) {
$suggest = DI::fsuggest()->getById($target_id);
@ -100,8 +118,8 @@ class Notifier
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'batch'], $condition);
} else {
// find ancestors
$condition = ['id' => $target_id, 'visible' => true, 'moderated' => false];
$target_item = Post::selectFirst([], $condition);
$condition = ['id' => $target_id, 'visible' => true];
$target_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition);
if (!DBA::isResult($target_item) || !intval($target_item['parent'])) {
Logger::info('No target item', ['cmd' => $cmd, 'target' => $target_id]);
@ -117,9 +135,9 @@ class Notifier
return;
}
$condition = ['parent' => $target_item['parent'], 'visible' => true, 'moderated' => false];
$condition = ['parent' => $target_item['parent'], 'visible' => true];
$params = ['order' => ['id']];
$items_stmt = Post::select([], $condition, $params);
$items_stmt = Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
if (!DBA::isResult($items_stmt)) {
Logger::info('No item found', ['cmd' => $cmd, 'target' => $target_id]);
return;
@ -305,8 +323,8 @@ class Notifier
/// @todo Possibly we should not uplink when the author is the forum itself?
if ((intval($parent['forum_mode']) == 1) && !$top_level && ($cmd !== Delivery::UPLINK)
&& ($target_item['verb'] != Activity::ANNOUNCE)) {
Worker::add($a->queue['priority'], 'Notifier', Delivery::UPLINK, $target_id);
&& ($target_item['verb'] != Activity::ANNOUNCE)) {
Worker::add($a->queue['priority'], 'Notifier', Delivery::UPLINK, $post_uriid, $sender_uid);
}
foreach ($items as $item) {
@ -452,13 +470,13 @@ class Notifier
$conversants = array_merge($contacts, $relay_list);
$delivery_queue_count += self::delivery($cmd, $target_id, $target_item, $thr_parent, $owner, $batch_delivery, true, $conversants, $ap_contacts, []);
$delivery_queue_count += self::delivery($cmd, $post_uriid, $sender_uid, $target_item, $thr_parent, $owner, $batch_delivery, true, $conversants, $ap_contacts, []);
$push_notify = true;
}
$contacts = DBA::toArray($delivery_contacts_stmt);
$delivery_queue_count += self::delivery($cmd, $target_id, $target_item, $thr_parent, $owner, $batch_delivery, false, $contacts, $ap_contacts, $conversants);
$delivery_queue_count += self::delivery($cmd, $post_uriid, $sender_uid, $target_item, $thr_parent, $owner, $batch_delivery, false, $contacts, $ap_contacts, $conversants);
$delivery_queue_count += self::deliverOStatus($target_id, $target_item, $owner, $url_recipients, $public_message, $push_notify);
@ -487,7 +505,8 @@ class Notifier
* Deliver the message to the contacts
*
* @param string $cmd
* @param int $target_id
* @param int $post_uriid
* @param int $sender_uid
* @param array $target_item
* @param array $thr_parent
* @param array $owner
@ -499,7 +518,7 @@ class Notifier
* @throws InternalServerErrorException
* @throws Exception
*/
private static function delivery(string $cmd, int $target_id, array $target_item, array $thr_parent, array $owner, bool $batch_delivery, bool $in_batch, array $contacts, array $ap_contacts, array $conversants = [])
private static function delivery(string $cmd, int $post_uriid, int $sender_uid, array $target_item, array $thr_parent, array $owner, bool $batch_delivery, bool $in_batch, array $contacts, array $ap_contacts, array $conversants = [])
{
$a = DI::app();
$delivery_queue_count = 0;
@ -511,38 +530,38 @@ class Notifier
}
if (in_array($contact['id'], $ap_contacts)) {
Logger::info('Contact is already delivered via AP, so skip delivery via legacy DFRN/Diaspora', ['target' => $target_id, 'contact' => $contact['url']]);
Logger::info('Contact is already delivered via AP, so skip delivery via legacy DFRN/Diaspora', ['target' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact['url']]);
continue;
}
if (!empty($contact['id']) && Contact::isArchived($contact['id'])) {
Logger::info('Contact is archived, so skip delivery', ['target' => $target_id, 'contact' => $contact['url']]);
Logger::info('Contact is archived, so skip delivery', ['target' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact['url']]);
continue;
}
if (self::isRemovalActivity($cmd, $owner, $contact['network'])) {
Logger::info('Contact does no supports account removal commands, so skip delivery', ['target' => $target_id, 'contact' => $contact['url']]);
Logger::info('Contact does no supports account removal commands, so skip delivery', ['target' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact['url']]);
continue;
}
if (self::skipActivityPubForDiaspora($contact, $target_item, $thr_parent)) {
Logger::info('Contact is from Diaspora, but the replied author is from ActivityPub, so skip delivery via Diaspora', ['id' => $target_id, 'url' => $contact['url']]);
Logger::info('Contact is from Diaspora, but the replied author is from ActivityPub, so skip delivery via Diaspora', ['id' => $post_uriid, 'uid' => $sender_uid, 'url' => $contact['url']]);
continue;
}
// Don't deliver to Diaspora if it already had been done as batch delivery
if (!$in_batch && $batch_delivery && ($contact['network'] == Protocol::DIASPORA)) {
Logger::info('Diaspora contact is already delivered via batch', ['id' => $target_id, 'contact' => $contact]);
Logger::info('Diaspora contact is already delivered via batch', ['id' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact]);
continue;
}
// Don't deliver to folks who have already been delivered to
if (in_array($contact['id'], $conversants)) {
Logger::info('Already delivery', ['id' => $target_id, 'contact' => $contact]);
Logger::info('Already delivery', ['id' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact]);
continue;
}
Logger::info('Delivery', ['batch' => $in_batch, 'target' => $target_id, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]);
Logger::info('Delivery', ['batch' => $in_batch, 'target' => $post_uriid, 'uid' => $sender_uid, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]);
// Ensure that posts with our own protocol arrives before Diaspora posts arrive.
// Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.
@ -554,7 +573,7 @@ class Notifier
$deliver_options = ['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true];
}
if (Worker::add($deliver_options, 'Delivery', $cmd, $target_id, (int)$contact['id'])) {
if (Worker::add($deliver_options, 'Delivery', $cmd, $post_uriid, (int)$contact['id'], $sender_uid)) {
$delivery_queue_count++;
}
}
@ -767,7 +786,7 @@ class Notifier
Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'id' => $target_item['id'], 'inbox' => $inbox]);
if (Worker::add(['priority' => $priority, 'created' => $created, 'dont_fork' => true],
'APDelivery', $cmd, $target_item['id'], $inbox, $uid, $receivers)) {
'APDelivery', $cmd, $target_item['id'], $inbox, $uid, $receivers, $target_item['uri-id'])) {
$delivery_queue_count++;
}
}
@ -776,7 +795,7 @@ class Notifier
foreach ($relay_inboxes as $inbox) {
Logger::info('Delivery to relay servers via ActivityPub', ['cmd' => $cmd, 'id' => $target_item['id'], 'inbox' => $inbox]);
if (Worker::add(['priority' => $priority, 'dont_fork' => true], 'APDelivery', $cmd, $target_item['id'], $inbox, $uid)) {
if (Worker::add(['priority' => $priority, 'dont_fork' => true], 'APDelivery', $cmd, $target_item['id'], $inbox, $uid, [], $target_item['uri-id'])) {
$delivery_queue_count++;
}
}
@ -792,6 +811,6 @@ class Notifier
*/
public static function isForumPost(array $item)
{
return !empty($item['forum_mode']);
return ($item['gravity'] == GRAVITY_PARENT) && !empty($item['forum_mode']);
}
}

View file

@ -23,6 +23,7 @@ namespace Friendica\Worker;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\Model\Photo;
use Friendica\Model\Post;
@ -47,13 +48,16 @@ class RemoveContact {
$condition = ['uid' => $contact['uid'], 'contact-id' => $id];
}
do {
$items = Post::select(['id', 'guid', 'uri-id', 'uid'], $condition, ['limit' => 100]);
$items = Post::select(['item-id', 'post-user-id', 'uri-id', 'guid'], $condition, ['limit' => 100]);
while ($item = Post::fetch($items)) {
Logger::info('Delete removed contact item', ['id' => $item['id'], 'guid' => $item['guid']]);
DBA::delete('item', ['id' => $item['id']]);
Post\User::delete(['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
Logger::info('Delete removed contact item', ['id' => $item['item-id'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
if (DBStructure::existsTable('item')) {
DBA::delete('item', ['id' => $item['item-id']]);
}
Post::delete(['uri-id' => $item['uri-id']]);
Post\ThreadUser::delete(['post-user-id' => $item['post-user-id']]);
Post\Thread::delete(['uri-id' => $item['uri-id']]);
Post\ThreadUser::delete(['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
Post\User::delete(['id' => $item['post-user-id']]);
}
DBA::close($items);
} while (Post::exists($condition));

View file

@ -35,9 +35,9 @@ class RemoveUnusedAvatars
public static function execute()
{
$condition = ["`uid` = ? AND NOT `self` AND NOT `nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` != ?)
AND `id` IN (SELECT `contact-id` FROM `photo`) AND NOT `id` IN (SELECT `author-id` FROM `item`)
AND NOT `id` IN (SELECT `owner-id` FROM `item`) AND NOT `id` IN (SELECT `causer-id` FROM `item`)
AND NOT `id` IN (SELECT `cid` FROM `post-tag`) AND NOT `id` IN (SELECT `contact-id` FROM `item`)", 0, 0];
AND `id` IN (SELECT `contact-id` FROM `photo`) AND NOT `id` IN (SELECT `author-id` FROM `post-user`)
AND NOT `id` IN (SELECT `owner-id` FROM `post-user`) AND NOT `id` IN (SELECT `causer-id` FROM `post-user`)
AND NOT `id` IN (SELECT `cid` FROM `post-tag`) AND NOT `id` IN (SELECT `contact-id` FROM `post-user`)", 0, 0];
$total = DBA::count('contact', $condition);
Logger::notice('Starting removal', ['total' => $total]);

View file

@ -36,11 +36,9 @@ class RemoveUnusedContacts
{
$condition = ["`uid` = ? AND NOT `self` AND NOT `nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` != ?)
AND (NOT `network` IN (?, ?, ?, ?, ?, ?) OR (`archive` AND `success_update` < UTC_TIMESTAMP() - INTERVAL ? DAY))
AND NOT `id` IN (SELECT `author-id` FROM `item`) AND NOT `id` IN (SELECT `owner-id` FROM `item`)
AND NOT `id` IN (SELECT `causer-id` FROM `item`) AND NOT `id` IN (SELECT `cid` FROM `post-tag`)
AND NOT `id` IN (SELECT `contact-id` FROM `item`) AND NOT `id` IN (SELECT `author-id` FROM `post-thread`)
AND NOT `id` IN (SELECT `owner-id` FROM `post-thread`) AND NOT `id` IN (SELECT `causer-id` FROM `post-thread`)
AND NOT `id` IN (SELECT `contact-id` FROM `post-user`) AND NOT `id` IN (SELECT `cid` FROM `user-contact`)
AND NOT `id` IN (SELECT `author-id` FROM `post-user`) AND NOT `id` IN (SELECT `owner-id` FROM `post-user`)
AND NOT `id` IN (SELECT `causer-id` FROM `post-user`) AND NOT `id` IN (SELECT `cid` FROM `post-tag`)
AND NOT `id` IN (SELECT `contact-id` FROM `post-user`) AND NOT `id` IN (SELECT `cid` FROM `user-contact`)
AND NOT `id` IN (SELECT `cid` FROM `event`) AND NOT `id` IN (SELECT `contact-id` FROM `group_member`)",
0, 0, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL, Protocol::ACTIVITYPUB, 365];
@ -54,6 +52,26 @@ class RemoveUnusedContacts
DBA::delete('thread', ['owner-id' => $contact['id']]);
DBA::delete('thread', ['author-id' => $contact['id']]);
}
if (DBStructure::existsTable('item')) {
DBA::delete('item', ['owner-id' => $contact['id']]);
DBA::delete('item', ['author-id' => $contact['id']]);
DBA::delete('item', ['causer-id' => $contact['id']]);
}
// There should be none entry for the contact in these tables when none was found in "post-user".
// But we want to be sure since the foreign key prohibits deletion otherwise.
DBA::delete('post', ['owner-id' => $contact['id']]);
DBA::delete('post', ['author-id' => $contact['id']]);
DBA::delete('post', ['causer-id' => $contact['id']]);
DBA::delete('post-thread', ['owner-id' => $contact['id']]);
DBA::delete('post-thread', ['author-id' => $contact['id']]);
DBA::delete('post-thread', ['causer-id' => $contact['id']]);
DBA::delete('post-thread-user', ['owner-id' => $contact['id']]);
DBA::delete('post-thread-user', ['author-id' => $contact['id']]);
DBA::delete('post-thread-user', ['causer-id' => $contact['id']]);
DBA::delete('contact', ['id' => $contact['id']]);
if ((++$count % 1000) == 0) {
Logger::notice('In removal', ['count' => $count, 'total' => $total]);

View file

@ -1,68 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Worker;
use Friendica\Database\DBA;
use Friendica\Model\ItemURI;
/**
* Do some repairs in database entries
* @todo This class can be deleted without replacement when the item table is removed
*/
class RepairDatabase
{
public static function execute()
{
// Ensure that there are no "uri-id", "parent-uri-id" or "thr-parent-id" fields that are NULL
$items = DBA::select('item', ['id', 'uri', 'guid'], ["`uri-id` IS NULL"]);
while ($item = DBA::fetch($items)) {
$uriid = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
DBA::update('item', ['uri-id' => $uriid], ['id' => $item['id']]);
}
DBA::close($items);
$items = DBA::select('item', ['id', 'parent-uri'], ["`parent-uri-id` IS NULL"]);
while ($item = DBA::fetch($items)) {
$uriid = ItemURI::getIdByURI($item['parent-uri']);
DBA::update('item', ['parent-uri-id' => $uriid], ['id' => $item['id']]);
}
DBA::close($items);
$items = DBA::select('item', ['id', 'thr-parent'], ["`thr-parent-id` IS NULL"]);
while ($item = DBA::fetch($items)) {
$uriid = ItemURI::getIdByURI($item['thr-parent']);
DBA::update('item', ['thr-parent-id' => $uriid], ['id' => $item['id']]);
}
DBA::close($items);
// Ensure that all uri-id are set correctly
DBA::e("UPDATE `item` INNER JOIN `item-uri` ON `item-uri`.`uri` = `item`.`uri`
SET `uri-id` = `item-uri`.`id` WHERE `item`.`uri-id` != `item-uri`.`id` AND `item`.`uri` != ?", '');
DBA::e("UPDATE `item` INNER JOIN `item-uri` ON `item-uri`.`uri` = `item`.`parent-uri`
SET `parent-uri-id` = `item-uri`.`id` WHERE `item`.`parent-uri-id` != `item-uri`.`id` AND `item`.`parent-uri` != ?", '');
DBA::e("UPDATE `item` INNER JOIN `item-uri` ON `item-uri`.`uri` = `item`.`thr-parent`
SET `thr-parent-id` = `item-uri`.`id` WHERE `item`.`thr-parent-id` != `item-uri`.`id` AND `item`.`thr-parent` != ?", '');
// Delete orphaned data from notify table.
DBA::e("DELETE FROM `notify` WHERE NOT `type` IN (1, 2, 16, 32, 512) AND NOT `iid` IN (SELECT `id` FROM `item`)");
}
}

View file

@ -51,8 +51,8 @@ class UpdateContacts
// Add every contact our system interacted with and hadn't been updated for a week if unarchived
// or for a month if archived.
$condition = DBA::mergeConditions($base_condition, ["(`id` IN (SELECT `author-id` FROM `item`) OR
`id` IN (SELECT `owner-id` FROM `item`) OR `id` IN (SELECT `causer-id` FROM `item`) OR
$condition = DBA::mergeConditions($base_condition, ["(`id` IN (SELECT `author-id` FROM `post-user`) OR
`id` IN (SELECT `owner-id` FROM `post-user`) OR `id` IN (SELECT `causer-id` FROM `post-user`) OR
`id` IN (SELECT `cid` FROM `post-tag`) OR `id` IN (SELECT `cid` FROM `user-contact`) OR `uid` != ?) AND
(`last-update` < ? OR (NOT `archive` AND `last-update` < ?))",
0, DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]);

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1399);
define('DB_UPDATE_VERSION', 1400);
}
return [
@ -771,7 +771,6 @@ return [
"global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"private" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "0=public, 1=private, 2=unlisted"],
"visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"],
// Part of "post-user". Will be deprecated in a later step
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
@ -787,10 +786,11 @@ return [
// It has to be decided whether these fields belong to the user or the structure
"event-id" => ["type" => "int unsigned", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"],
// Check deprecation status
"type" => ["type" => "varchar(20)", "comment" => ""],
"bookmark" => ["type" => "boolean", "comment" => ""],
"mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The owner of this item was mentioned in it"],
// Deprecated fields. Will be removed in upcoming versions
// Deprecated fields. Will not be transferred to the "post" table
"bookmark" => ["type" => "boolean", "comment" => "Deprecated"],
"type" => ["type" => "varchar(20)", "comment" => "Deprecated"],
"moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Deprecated"],
"resource-id" => ["type" => "varchar(32)", "comment" => "Deprecated"],
"uri-hash" => ["type" => "varchar(80)", "comment" => "Deprecated"],
"iaid" => ["type" => "int unsigned", "comment" => "Deprecated"],
@ -1086,6 +1086,40 @@ return [
"resource-id" => ["resource-id"],
]
],
"post" => [
"comment" => "Structure for all posts",
"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 item uri"],
"parent-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the parent uri"],
"thr-parent-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the thread parent uri"],
"external-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the external uri"],
"created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Creation timestamp."],
"edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of last edit (default is created)"],
"received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime"],
"gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
"network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
"owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the owner of this item"],
"author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
"causer-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the contact that caused the item creation"],
"post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
"vid" => ["type" => "smallint unsigned", "foreign" => ["verb" => "id", "on delete" => "restrict"], "comment" => "Id of the verb table entry that contains the activity verbs"],
"private" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "0=public, 1=private, 2=unlisted"],
"global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been marked for deletion"]
],
"indexes" => [
"PRIMARY" => ["uri-id"],
"parent-uri-id" => ["parent-uri-id"],
"thr-parent-id" => ["thr-parent-id"],
"external-id" => ["external-id"],
"owner-id" => ["owner-id"],
"author-id" => ["author-id"],
"causer-id" => ["causer-id"],
"vid" => ["vid"],
"received" => ["received"],
]
],
"post-category" => [
"comment" => "post relation to categories",
"fields" => [
@ -1209,12 +1243,31 @@ return [
"fields" => [
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"],
"uri-id" => ["type" => "int unsigned", "not null" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
"parent-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the parent uri"],
"thr-parent-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the thread parent uri"],
"external-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the external uri"],
"created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Creation timestamp."],
"edited" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of last edit (default is created)"],
"received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime"],
"gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
"network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
"owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the owner of this item"],
"author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
"causer-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the contact that caused the item creation"],
"post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
"vid" => ["type" => "smallint unsigned", "foreign" => ["verb" => "id", "on delete" => "restrict"], "comment" => "Id of the verb table entry that contains the activity verbs"],
"private" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "0=public, 1=private, 2=unlisted"],
"global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been marked for deletion"],
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "foreign" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
"protocol" => ["type" => "tinyint unsigned", "comment" => "Protocol used to deliver the item for this user"],
"contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "contact.id"],
"event-id" => ["type" => "int unsigned", "foreign" => ["event" => "id"], "comment" => "Used to link to the event.id"],
"unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "post has not been seen"],
"hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide the post from the user"],
"notification-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
"wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
"origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"],
"psid" => ["type" => "int unsigned", "foreign" => ["permissionset" => "id", "on delete" => "restrict"], "comment" => "ID of the permission set of this post"],
],
@ -1225,12 +1278,37 @@ return [
"contact-id" => ["contact-id"],
"psid" => ["psid"],
"uid_hidden" => ["uid", "hidden"],
"event-id" => ["event-id"],
"uid_wall" => ["uid", "wall"],
"parent-uri-id" => ["parent-uri-id"],
"thr-parent-id" => ["thr-parent-id"],
"external-id" => ["external-id"],
"owner-id" => ["owner-id"],
"author-id" => ["author-id"],
"causer-id" => ["causer-id"],
"vid" => ["vid"],
"uid_received" => ["uid", "received"],
"uid_unseen_contactid" => ["uid", "unseen", "contact-id"],
"uid_network_received" => ["uid", "network", "received"],
"uid_contactid_received" => ["uid", "contact-id", "received"],
"authorid_received" => ["author-id", "received"],
"uid_unseen_wall" => ["uid", "unseen", "wall"],
"uid_eventid" => ["uid", "event-id"],
"psid_wall" => ["psid", "wall"],
],
],
"post-thread-user" => [
"comment" => "Thread related data per user",
"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 item uri"],
"owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Item owner"],
"author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Item author"],
"causer-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the contact that caused the item creation"],
"network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
"created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
"received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
"changed" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date that something in the conversation changed, indicating clients should fetch the conversation again"],
"commented" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "foreign" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
"pinned" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The thread is pinned on the profile page"],
"starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
@ -1254,6 +1332,24 @@ return [
"contact-id" => ["contact-id"],
"psid" => ["psid"],
"post-user-id" => ["post-user-id"],
"owner-id" => ["owner-id"],
"causer-id" => ["causer-id"],
"uid_received" => ["uid", "received"],
"uid_commented" => ["uid", "commented"],
"uid_changed" => ["uid", "changed"],
"uid_contact-id" => ["uid", "contact-id", "received"],
"uid_unseen_contactid" => ["uid", "unseen", "contact-id"],
"uid_network_received" => ["uid", "network", "received"],
"uid_network_commented" => ["uid", "network", "commented"],
"uid_contact-id_received" => ["uid", "contact-id", "received"],
"author-id_received" => ["author-id", "received"],
"uid_wall_changed" => ["uid", "wall", "changed"],
"uid_unseen_wall" => ["uid", "unseen", "wall"],
"mention_uid" => ["mention", "uid"],
"psid_wall" => ["psid", "wall"],
"received" => ["received"],
"commented" => ["commented"],
"changed" => ["changed"],
]
],
"post-user-notification" => [

View file

@ -39,44 +39,42 @@
return [
"post-view" => [
"fields" => [
"id" => ["item", "id"],
"item_id" => ["item", "id"],
"id" => ["post-user", "id"],
"item-id" => ["item", "id"],
"post-user-id" => ["post-user", "id"],
"uid" => ["item", "uid"],
"parent" => ["item", "parent"],
"uri" => ["item", "uri"],
"uri-id" => ["item", "uri-id"],
"parent-uri" => ["item", "parent-uri"],
"parent-uri-id" => ["item", "parent-uri-id"],
"thr-parent" => ["item", "thr-parent"],
"thr-parent-id" => ["item", "thr-parent-id"],
"guid" => ["item", "guid"],
"type" => ["item", "type"],
"wall" => ["item", "wall"],
"gravity" => ["item", "gravity"],
"extid" => ["item", "extid"],
"created" => ["item", "created"],
"edited" => ["item", "edited"],
"commented" => ["item", "commented"],
"received" => ["item", "received"],
"changed" => ["item", "changed"],
"post-type" => ["item", "post-type"],
"private" => ["item", "private"],
"pubmail" => ["item", "pubmail"],
"moderated" => ["item", "moderated"],
"visible" => ["item", "visible"],
"starred" => ["item", "starred"],
"bookmark" => ["item", "bookmark"],
"unseen" => ["item", "unseen"],
"deleted" => ["item", "deleted"],
"origin" => ["item", "origin"],
"forum_mode" => ["item", "forum_mode"],
"mention" => ["item", "mention"],
"global" => ["item", "global"],
"network" => ["item", "network"],
"vid" => ["item", "vid"],
"psid" => ["item", "psid"],
"verb" => "IF (`item`.`vid` IS NULL, '', `verb`.`name`)",
"uid" => ["post-user", "uid"],
"parent" => ["parent-post", "id"],
"uri" => ["item-uri", "uri"],
"uri-id" => ["post-user", "uri-id"],
"parent-uri" => ["parent-item-uri", "uri"],
"parent-uri-id" => ["post-user", "parent-uri-id"],
"thr-parent" => ["thr-parent-item-uri", "uri"],
"thr-parent-id" => ["post-user", "thr-parent-id"],
"guid" => ["item-uri", "guid"],
"wall" => ["post-user", "wall"],
"gravity" => ["post-user", "gravity"],
"extid" => ["external-item-uri", "uri"],
"external-id" => ["post-user", "external-id"],
"created" => ["post-user", "created"],
"edited" => ["post-user", "edited"],
"commented" => ["post-thread-user", "commented"],
"received" => ["post-user", "received"],
"changed" => ["post-thread-user", "changed"],
"post-type" => ["post-user", "post-type"],
"private" => ["post-user", "private"],
"pubmail" => ["post-thread-user", "pubmail"],
"visible" => ["post-user", "visible"],
"starred" => ["post-thread-user", "starred"],
"unseen" => ["post-user", "unseen"],
"deleted" => ["post-user", "deleted"],
"origin" => ["post-user", "origin"],
"forum_mode" => ["post-thread-user", "forum_mode"],
"mention" => ["post-thread-user", "mention"],
"global" => ["post-user", "global"],
"network" => ["post-user", "network"],
"vid" => ["post-user", "vid"],
"psid" => ["post-user", "psid"],
"verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
"title" => ["post-content", "title"],
"content-warning" => ["post-content", "content-warning"],
"raw-body" => ["post-content", "raw-body"],
@ -93,7 +91,7 @@
"target-type" => ["post-content", "target-type"],
"target" => ["post-content", "target"],
"resource-id" => ["post-content", "resource-id"],
"contact-id" => ["item", "contact-id"],
"contact-id" => ["post-user", "contact-id"],
"contact-link" => ["contact", "url"],
"contact-addr" => ["contact", "addr"],
"contact-name" => ["contact", "name"],
@ -108,7 +106,7 @@
"contact-rel" => ["contact", "rel"],
"contact-uid" => ["contact", "uid"],
"contact-contact-type" => ["contact", "contact-type"],
"writable" => "IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
"writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
"self" => ["contact", "self"],
"cid" => ["contact", "id"],
"alias" => ["contact", "alias"],
@ -118,7 +116,7 @@
"avatar-date" => ["contact", "avatar-date"],
"thumb" => ["contact", "thumb"],
"dfrn-id" => ["contact", "dfrn-id"],
"author-id" => ["item", "author-id"],
"author-id" => ["post-user", "author-id"],
"author-link" => ["author", "url"],
"author-addr" => ["author", "addr"],
"author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
@ -127,7 +125,7 @@
"author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"],
"author-hidden" => ["author", "hidden"],
"owner-id" => ["item", "owner-id"],
"owner-id" => ["post-user", "owner-id"],
"owner-link" => ["owner", "url"],
"owner-addr" => ["owner", "addr"],
"owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
@ -136,7 +134,7 @@
"owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"],
"owner-hidden" => ["owner", "hidden"],
"causer-id" => ["item", "causer-id"],
"causer-id" => ["post-user", "causer-id"],
"causer-link" => ["causer", "url"],
"causer-addr" => ["causer", "addr"],
"causer-name" => ["causer", "name"],
@ -151,11 +149,11 @@
"delivery_queue_count" => ["post-delivery-data", "queue_count"],
"delivery_queue_done" => ["post-delivery-data", "queue_done"],
"delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
"allow_cid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
"allow_gid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
"deny_cid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
"deny_gid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
"event-id" => ["item", "event-id"],
"allow_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
"allow_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
"deny_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
"deny_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
"event-id" => ["post-user", "event-id"],
"event-created" => ["event", "created"],
"event-edited" => ["event", "edited"],
"event-start" => ["event", "start"],
@ -168,69 +166,73 @@
"event-adjust" => ["event", "adjust"],
"event-ignore" => ["event", "ignore"],
"signed_text" => ["diaspora-interaction", "interaction"],
"parent-guid" => ["parent-item", "guid"],
"parent-network" => ["parent-item", "network"],
"parent-author-id" => ["parent-item", "author-id"],
"parent-author-link" => ["parent-item-author", "url"],
"parent-author-name" => ["parent-item-author", "name"],
"parent-author-network" => ["parent-item-author", "network"],
"parent-guid" => ["parent-item-uri", "guid"],
"parent-network" => ["parent-post", "network"],
"parent-author-id" => ["parent-post", "author-id"],
"parent-author-link" => ["parent-post-author", "url"],
"parent-author-name" => ["parent-post-author", "name"],
"parent-author-network" => ["parent-post-author", "network"],
],
"query" => "FROM `item`
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `item`.`uid`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `item`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id` AND `parent-item`.`uid` = `item`.`uid`
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`"
"query" => "FROM `post-user`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
LEFT JOIN `item` ON `item`.`uri-id` = `post-user`.`uri-id` AND `item`.`uid` = `post-user`.`uid`
INNER JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
INNER JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
INNER JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
INNER JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
INNER JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
INNER JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
INNER JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
INNER JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
INNER JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
],
"post-thread-view" => [
"fields" => [
"id" => ["item", "id"],
"iid" => ["item", "id"],
"item_id" => ["item", "id"],
"id" => ["post-user", "id"],
"item-id" => ["item", "id"],
"iid" => ["post-user", "id"],
"post-user-id" => ["post-user", "id"],
"uid" => ["post-thread-user", "uid"],
"parent" => ["item", "parent"],
"uri" => ["item", "uri"],
"uri-id" => ["post-thread", "uri-id"],
"parent-uri" => ["item", "parent-uri"],
"parent-uri-id" => ["item", "parent-uri-id"],
"thr-parent" => ["item", "thr-parent"],
"thr-parent-id" => ["item", "thr-parent-id"],
"guid" => ["item", "guid"],
"type" => ["item", "type"],
"parent" => ["parent-post", "id"],
"uri" => ["item-uri", "uri"],
"uri-id" => ["post-thread-user", "uri-id"],
"parent-uri" => ["parent-item-uri", "uri"],
"parent-uri-id" => ["post-user", "parent-uri-id"],
"thr-parent" => ["thr-parent-item-uri", "uri"],
"thr-parent-id" => ["post-user", "thr-parent-id"],
"guid" => ["item-uri", "guid"],
"wall" => ["post-thread-user", "wall"],
"gravity" => ["item", "gravity"],
"extid" => ["item", "extid"],
"created" => ["post-thread", "created"],
"edited" => ["item", "edited"],
"commented" => ["post-thread", "commented"],
"received" => ["post-thread", "received"],
"changed" => ["post-thread", "changed"],
"post-type" => ["item", "post-type"],
"private" => ["item", "private"],
"gravity" => ["post-user", "gravity"],
"extid" => ["external-item-uri", "uri"],
"external-id" => ["post-user", "external-id"],
"created" => ["post-thread-user", "created"],
"edited" => ["post-user", "edited"],
"commented" => ["post-thread-user", "commented"],
"received" => ["post-thread-user", "received"],
"changed" => ["post-thread-user", "changed"],
"post-type" => ["post-user", "post-type"],
"private" => ["post-user", "private"],
"pubmail" => ["post-thread-user", "pubmail"],
"moderated" => ["item", "moderated"],
"ignored" => ["post-thread-user", "ignored"],
"visible" => ["item", "visible"],
"visible" => ["post-user", "visible"],
"starred" => ["post-thread-user", "starred"],
"bookmark" => ["item", "bookmark"],
"unseen" => ["post-thread-user", "unseen"],
"deleted" => ["item", "deleted"],
"deleted" => ["post-user", "deleted"],
"origin" => ["post-thread-user", "origin"],
"forum_mode" => ["post-thread-user", "forum_mode"],
"mention" => ["item", "mention"],
"global" => ["item", "global"],
"network" => ["post-thread", "network"],
"vid" => ["item", "vid"],
"mention" => ["post-thread-user", "mention"],
"global" => ["post-user", "global"],
"network" => ["post-thread-user", "network"],
"vid" => ["post-user", "vid"],
"psid" => ["post-thread-user", "psid"],
"verb" => "IF (`item`.`vid` IS NULL, '', `verb`.`name`)",
"verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
"title" => ["post-content", "title"],
"content-warning" => ["post-content", "content-warning"],
"raw-body" => ["post-content", "raw-body"],
@ -262,7 +264,7 @@
"contact-rel" => ["contact", "rel"],
"contact-uid" => ["contact", "uid"],
"contact-contact-type" => ["contact", "contact-type"],
"writable" => "IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
"writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
"self" => ["contact", "self"],
"cid" => ["contact", "id"],
"alias" => ["contact", "alias"],
@ -272,7 +274,7 @@
"avatar-date" => ["contact", "avatar-date"],
"thumb" => ["contact", "thumb"],
"dfrn-id" => ["contact", "dfrn-id"],
"author-id" => ["post-thread", "author-id"],
"author-id" => ["post-thread-user", "author-id"],
"author-link" => ["author", "url"],
"author-addr" => ["author", "addr"],
"author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
@ -281,7 +283,7 @@
"author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"],
"author-hidden" => ["author", "hidden"],
"owner-id" => ["post-thread", "owner-id"],
"owner-id" => ["post-thread-user", "owner-id"],
"owner-link" => ["owner", "url"],
"owner-addr" => ["owner", "addr"],
"owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
@ -290,7 +292,7 @@
"owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"],
"owner-hidden" => ["owner", "hidden"],
"causer-id" => ["item", "causer-id"],
"causer-id" => ["post-thread-user", "causer-id"],
"causer-link" => ["causer", "url"],
"causer-addr" => ["causer", "addr"],
"causer-name" => ["causer", "name"],
@ -309,7 +311,7 @@
"allow_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
"deny_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
"deny_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
"event-id" => ["item", "event-id"],
"event-id" => ["post-user", "event-id"],
"event-created" => ["event", "created"],
"event-edited" => ["event", "edited"],
"event-start" => ["event", "start"],
@ -322,49 +324,48 @@
"event-adjust" => ["event", "adjust"],
"event-ignore" => ["event", "ignore"],
"signed_text" => ["diaspora-interaction", "interaction"],
"parent-guid" => ["parent-item", "guid"],
"parent-network" => ["parent-item", "network"],
"parent-author-id" => ["parent-item", "author-id"],
"parent-author-link" => ["parent-item-author", "url"],
"parent-author-name" => ["parent-item-author", "name"],
"parent-author-network" => ["parent-item-author", "network"],
"parent-guid" => ["parent-item-uri", "guid"],
"parent-network" => ["parent-post", "network"],
"parent-author-id" => ["parent-post", "author-id"],
"parent-author-link" => ["parent-post-author", "url"],
"parent-author-name" => ["parent-post-author", "name"],
"parent-author-network" => ["parent-post-author", "network"],
],
"query" => "FROM `post-thread`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread`.`uri-id` AND `post-thread-user`.`origin`
"query" => "FROM `post-thread-user`
INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
LEFT JOIN `item` ON `item`.`uri-id` = `post-thread-user`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
INNER JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
INNER JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
INNER JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
INNER JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
INNER JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
INNER JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
INNER JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`"
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
INNER JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
],
"category-view" => [
"fields" => [
"uri-id" => ["post-category", "uri-id"],
"uid" => ["post-category", "uid"],
"uri" => ["item-uri", "uri"],
"guid" => ["item-uri", "guid"],
"type" => ["post-category", "type"],
"tid" => ["post-category", "tid"],
"name" => ["tag", "name"],
"url" => ["tag", "url"],
],
"query" => "FROM `post-category`
INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
],
"tag-view" => [
"fields" => [
"uri-id" => ["post-tag", "uri-id"],
"uri" => ["item-uri", "uri"],
"guid" => ["item-uri", "guid"],
"type" => ["post-tag", "type"],
"tid" => ["post-tag", "tid"],
"cid" => ["post-tag", "cid"],
@ -372,35 +373,33 @@
"url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
],
"query" => "FROM `post-tag`
INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
],
"network-item-view" => [
"fields" => [
"uri-id" => ["item", "parent-uri-id"],
"uri" => ["item", "parent-uri"],
"parent" => ["item", "parent"],
"received" => ["item", "received"],
"commented" => ["item", "commented"],
"created" => ["item", "created"],
"uid" => ["item", "uid"],
"starred" => ["item", "starred"],
"mention" => ["item", "mention"],
"network" => ["item", "network"],
"unseen" => ["item", "unseen"],
"gravity" => ["item", "gravity"],
"contact-id" => ["item", "contact-id"],
"uri-id" => ["post-user", "uri-id"],
"parent" => ["parent-post", "id"],
"received" => ["post-user", "received"],
"commented" => ["post-thread-user", "commented"],
"created" => ["post-user", "created"],
"uid" => ["post-user", "uid"],
"starred" => ["post-thread-user", "starred"],
"mention" => ["post-thread-user", "mention"],
"network" => ["post-user", "network"],
"unseen" => ["post-user", "unseen"],
"gravity" => ["post-user", "gravity"],
"contact-id" => ["post-user", "contact-id"],
"contact-type" => ["ownercontact", "contact-type"],
],
"query" => "FROM `item`
INNER JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `parent-item`.`contact-id`
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `parent-item`.`uid`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `parent-item`.`uid` AND `author`.`cid` = `parent-item`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `parent-item`.`uid` AND `owner`.`cid` = `parent-item`.`owner-id`
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `parent-item`.`owner-id`
WHERE `parent-item`.`visible` AND NOT `parent-item`.`deleted` AND NOT `parent-item`.`moderated`
"query" => "FROM `post-user`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
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 (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
@ -408,28 +407,26 @@
],
"network-thread-view" => [
"fields" => [
"uri-id" => ["post-thread", "uri-id"],
"uri" => ["item", "uri"],
"parent-uri-id" => ["item", "parent-uri-id"],
"parent" => ["item", "id"],
"received" => ["post-thread", "received"],
"commented" => ["post-thread", "commented"],
"created" => ["post-thread", "created"],
"uri-id" => ["post-thread-user", "uri-id"],
"parent" => ["parent-post", "id"],
"received" => ["post-thread-user", "received"],
"commented" => ["post-thread-user", "commented"],
"created" => ["post-thread-user", "created"],
"uid" => ["post-thread-user", "uid"],
"starred" => ["post-thread-user", "starred"],
"mention" => ["post-thread-user", "mention"],
"network" => ["post-thread", "network"],
"network" => ["post-thread-user", "network"],
"contact-id" => ["post-thread-user", "contact-id"],
"contact-type" => ["ownercontact", "contact-type"],
],
"query" => "FROM `post-thread`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
"query" => "FROM `post-thread-user`
INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread`.`owner-id`
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread`.`owner-id`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
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 (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
@ -591,20 +588,18 @@
"tag-search-view" => [
"fields" => [
"uri-id" => ["post-tag", "uri-id"],
"iid" => ["item", "id"],
"uri" => ["item", "uri"],
"guid" => ["item", "guid"],
"uid" => ["item", "uid"],
"private" => ["item", "private"],
"wall" => ["item", "wall"],
"origin" => ["item", "origin"],
"gravity" => ["item", "gravity"],
"received" => ["item", "received"],
"uid" => ["post-user", "uid"],
"iid" => ["post-user", "id"],
"private" => ["post-user", "private"],
"wall" => ["post-user", "wall"],
"origin" => ["post-user", "origin"],
"gravity" => ["post-user", "gravity"],
"received" => ["post-user", "received"],
"name" => ["tag", "name"],
],
"query" => "FROM `post-tag`
INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
WHERE `post-tag`.`type` = 1"
],
"workerqueue-view" => [

View file

@ -405,10 +405,6 @@ return [
// Don't show smilies.
'no_smilies' => false,
// optimize_items (Boolean)
// Triggers an SQL command to optimize the item table before expiring items.
'optimize_items' => false,
// paranoia (Boolean)
// Log out users if their IP address changed.
'paranoia' => false,

View file

@ -50,6 +50,16 @@ return [
'k' => 'worker_dont_fork',
'v' => '1',
],
[
'cat' => 'system',
'k' => 'curl_timeout',
'v' => '1',
],
[
'cat' => 'system',
'k' => 'xrd_timeout',
'v' => '1',
],
],
'user' => [
[
@ -182,6 +192,44 @@ return [
'guid' => '6',
],
],
'verb' => [
[
'id' => 0,
'name' => '',
],
[
'id' => 1,
'name' => 'http://activitystrea.ms/schema/1.0/like',
],
[
'id' => 2,
'name' => 'http://purl.org/macgirvin/dfrn/1.0/dislike',
],
[
'id' => 3,
'name' => 'http://purl.org/zot/activity/attendyes',
],
[
'id' => 4,
'name' => 'http://purl.org/zot/activity/attendno',
],
[
'id' => 5,
'name' => 'http://purl.org/zot/activity/attendmaybe',
],
[
'id' => 6,
'name' => 'http://activitystrea.ms/schema/1.0/follow',
],
[
'id' => 7,
'name' => 'https://www.w3.org/ns/activitystreams#Announce',
],
[
'id' => 8,
'name' => 'http://activitystrea.ms/schema/1.0/post',
],
],
'post-content' => [
[
'uri-id' => 1,
@ -214,6 +262,333 @@ return [
'plink' => 'http://localhost/display/6',
],
],
'post' => [
[
'uri-id' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
],
[
'uri-id' => 2,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
],
[
'uri-id' => 3,
'parent-uri-id' => 3,
'thr-parent-id' => 3,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 43,
'causer-id' => 43,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
],
[
'uri-id' => 4,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
'causer-id' => 44,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
],
[
'uri-id' => 5,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
],
[
'uri-id' => 6,
'parent-uri-id' => 6,
'thr-parent-id' => 6,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
'causer-id' => 44,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
],
],
'post-user' => [
[
'id' => 1,
'uri-id' => 1,
'visible' => 1,
'contact-id' => 42,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'uid' => 42,
'vid' => 8,
'unseen' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'wall' => 1,
'origin' => 1,
],
[
'id' => 2,
'uri-id' => 2,
'uid' => 42,
'contact-id' => 42,
'unseen' => 0,
'origin' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 1,
],
[
'id' => 3,
'uri-id' => 3,
'uid' => 42,
'contact-id' => 43,
'unseen' => 0,
'origin' => 1,
'parent-uri-id' => 3,
'thr-parent-id' => 3,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 43,
'causer-id' => 43,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 1,
],
[
'id' => 4,
'uri-id' => 4,
'uid' => 42,
'contact-id' => 44,
'unseen' => 0,
'origin' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
'causer-id' => 44,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 1,
],
[
'id' => 5,
'uri-id' => 5,
'uid' => 42,
'contact-id' => 42,
'unseen' => 0,
'origin' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 1,
],
[
'id' => 6,
'uri-id' => 6,
'uid' => 42,
'contact-id' => 44,
'unseen' => 0,
'origin' => 1,
'parent-uri-id' => 6,
'thr-parent-id' => 6,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
'causer-id' => 44,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 1,
],
[
'id' => 7,
'uri-id' => 1,
'uid' => 0,
'contact-id' => 42,
'unseen' => 1,
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 0,
],
[
'id' => 8,
'uri-id' => 2,
'uid' => 0,
'contact-id' => 42,
'unseen' => 0,
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 0,
],
[
'id' => 9,
'uri-id' => 3,
'uid' => 0,
'contact-id' => 43,
'unseen' => 0,
'origin' => 0,
'parent-uri-id' => 3,
'thr-parent-id' => 3,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 43,
'causer-id' => 43,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 0,
],
[
'id' => 10,
'uri-id' => 4,
'uid' => 0,
'contact-id' => 44,
'unseen' => 0,
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
'causer-id' => 44,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 0,
],
[
'id' => 11,
'uri-id' => 5,
'uid' => 0,
'contact-id' => 42,
'unseen' => 0,
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
'causer-id' => 42,
'vid' => 8,
'private' => Item::PUBLIC,
'visible' => 1,
'deleted' => 0,
'wall' => 0,
],
[
'id' => 12,
'uri-id' => 6,
'visible' => 1,
'contact-id' => 44,
'author-id' => 44,
'owner-id' => 42,
'causer-id' => 44,
'uid' => 0,
'vid' => 8,
'unseen' => 0,
'parent-uri-id' => 6,
'thr-parent-id' => 6,
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'origin' => 0,
'deleted' => 0,
'wall' => 0,
],
],
'post-thread' => [
[
'uri-id' => 1,
@ -237,462 +612,84 @@ return [
'network' => Protocol::DFRN,
],
],
'post-user' => [
[
'id' => 1,
'uri-id' => 1,
'uid' => 42,
'contact-id' => 42,
'unseen' => 1,
'origin' => 1,
],
[
'id' => 2,
'uri-id' => 2,
'uid' => 42,
'contact-id' => 42,
'unseen' => 0,
'origin' => 1,
],
[
'id' => 3,
'uri-id' => 3,
'uid' => 42,
'contact-id' => 43,
'unseen' => 0,
'origin' => 1,
],
[
'id' => 4,
'uri-id' => 4,
'uid' => 42,
'contact-id' => 44,
'unseen' => 0,
'origin' => 1,
],
[
'id' => 5,
'uri-id' => 5,
'uid' => 42,
'contact-id' => 42,
'unseen' => 0,
'origin' => 1,
],
[
'id' => 6,
'uri-id' => 6,
'uid' => 42,
'contact-id' => 44,
'unseen' => 0,
'origin' => 1,
],
[
'id' => 7,
'uri-id' => 1,
'uid' => 0,
'contact-id' => 42,
'unseen' => 1,
'origin' => 0,
],
[
'id' => 8,
'uri-id' => 2,
'uid' => 0,
'contact-id' => 42,
'unseen' => 0,
'origin' => 0,
],
[
'id' => 9,
'uri-id' => 3,
'uid' => 0,
'contact-id' => 43,
'unseen' => 0,
'origin' => 0,
],
[
'id' => 10,
'uri-id' => 4,
'uid' => 0,
'contact-id' => 44,
'unseen' => 0,
'origin' => 0,
],
[
'id' => 11,
'uri-id' => 5,
'uid' => 0,
'contact-id' => 42,
'unseen' => 0,
'origin' => 0,
],
[
'id' => 12,
'uri-id' => 6,
'uid' => 0,
'contact-id' => 44,
'unseen' => 0,
'origin' => 0,
],
],
'post-thread-user' => [
[
'uri-id' => 1,
'uid' => 42,
'wall' => 1,
'post-user-id' => 1,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'contact-id' => 42,
'network' => Protocol::DFRN,
'starred' => 1,
'origin' => 1,
],
[
'uri-id' => 3,
'uid' => 42,
'wall' => 1,
'post-user-id' => 3,
'author-id' => 43,
'owner-id' => 43,
'causer-id' => 43,
'contact-id' => 43,
'network' => Protocol::DFRN,
'starred' => 0,
'origin' => 1,
],
[
'uri-id' => 6,
'uid' => 42,
'wall' => 1,
'post-user-id' => 6,
'author-id' => 44,
'owner-id' => 44,
'causer-id' => 44,
'contact-id' => 44,
'network' => Protocol::DFRN,
'starred' => 0,
'origin' => 1,
],
[
'uri-id' => 1,
'uid' => 0,
'wall' => 0,
'post-user-id' => 7,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'contact-id' => 42,
'network' => Protocol::DFRN,
'starred' => 0,
'origin' => 0,
],
[
'uri-id' => 3,
'uid' => 0,
'wall' => 0,
'post-user-id' => 9,
'author-id' => 43,
'owner-id' => 43,
'causer-id' => 43,
'contact-id' => 43,
'network' => Protocol::DFRN,
'starred' => 0,
'origin' => 0,
],
[
'uri-id' => 6,
'uid' => 0,
'wall' => 0,
'post-user-id' => 12,
],
],
'item' => [
[
'id' => 1,
'uri-id' => 1,
'uri' => '1',
'visible' => 1,
'contact-id' => 42,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'uid' => 42,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 1,
'parent' => 1,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'author-link' => 'http://localhost/profile/selfcontact',
'wall' => 1,
'starred' => 1,
'origin' => 1,
'allow_cid' => '',
'allow_gid' => '',
'deny_cid' => '',
'deny_gid' => '',
'guid' => '1',
],
[
'id' => 2,
'uri-id' => 2,
'uri' => '2',
'visible' => 1,
'contact-id' => 42,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'uid' => 42,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 1,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_COMMENT,
'author-link' => 'http://localhost/profile/selfcontact',
'wall' => 1,
'starred' => 0,
'origin' => 1,
'guid' => '2',
],
[
'id' => 3,
'uri-id' => 3,
'uri' => '3',
'visible' => 1,
'contact-id' => 43,
'author-id' => 43,
'owner-id' => 42,
'causer-id' => 43,
'uid' => 42,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 3,
'parent-uri-id' => 3,
'parent-uri' => '3',
'thr-parent-id' => 3,
'thr-parent' => '3',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 1,
'starred' => 0,
'origin' => 1,
'guid' => '3',
],
[
'id' => 4,
'uri-id' => 4,
'uri' => '4',
'visible' => 1,
'contact-id' => 44,
'author-id' => 44,
'owner-id' => 42,
'causer-id' => 44,
'uid' => 42,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'body' => 'Friend user reply',
'parent' => 1,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_COMMENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 1,
'starred' => 0,
'origin' => 1,
'guid' => '4',
],
[
'id' => 5,
'uri-id' => 5,
'uri' => '5',
'visible' => 1,
'contact-id' => 42,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'uid' => 42,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 1,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_COMMENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 1,
'starred' => 0,
'origin' => 1,
'allow_cid' => '',
'allow_gid' => '',
'deny_cid' => '',
'deny_gid' => '',
'guid' => '5',
],
[
'id' => 6,
'uri-id' => 6,
'uri' => '6',
'visible' => 1,
'contact-id' => 44,
'author-id' => 44,
'owner-id' => 42,
'causer-id' => 44,
'uid' => 42,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 6,
'parent-uri-id' => 6,
'parent-uri' => '6',
'thr-parent-id' => 6,
'thr-parent' => '6',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 1,
'starred' => 0,
'origin' => 1,
'guid' => '6',
],
[
'id' => 7,
'uri-id' => 1,
'uri' => '1',
'visible' => 1,
'contact-id' => 42,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'uid' => 0,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 1,
'parent' => 7,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'author-link' => 'http://localhost/profile/selfcontact',
'wall' => 0,
'starred' => 1,
'origin' => 0,
'allow_cid' => '',
'allow_gid' => '',
'deny_cid' => '',
'deny_gid' => '',
'guid' => '1',
],
[
'id' => 8,
'uri-id' => 2,
'uri' => '2',
'visible' => 1,
'contact-id' => 42,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'uid' => 0,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 7,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_COMMENT,
'author-link' => 'http://localhost/profile/selfcontact',
'wall' => 0,
'starred' => 0,
'origin' => 0,
'guid' => '2',
],
[
'id' => 9,
'uri-id' => 3,
'uri' => '3',
'visible' => 1,
'contact-id' => 43,
'author-id' => 43,
'owner-id' => 42,
'causer-id' => 43,
'uid' => 0,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 9,
'parent-uri-id' => 3,
'parent-uri' => '3',
'thr-parent-id' => 3,
'thr-parent' => '3',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 0,
'starred' => 0,
'origin' => 0,
'guid' => '3',
],
[
'id' => 10,
'uri-id' => 4,
'uri' => '4',
'visible' => 1,
'contact-id' => 44,
'author-id' => 44,
'owner-id' => 42,
'causer-id' => 44,
'uid' => 0,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'body' => 'Friend user reply',
'parent' => 7,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_COMMENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 0,
'starred' => 0,
'origin' => 0,
'guid' => '4',
],
[
'id' => 11,
'uri-id' => 5,
'uri' => '5',
'visible' => 1,
'contact-id' => 42,
'author-id' => 42,
'owner-id' => 42,
'causer-id' => 42,
'uid' => 0,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 7,
'parent-uri-id' => 1,
'parent-uri' => '1',
'thr-parent-id' => 1,
'thr-parent' => '1',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_COMMENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 0,
'starred' => 0,
'origin' => 1,
'allow_cid' => '',
'allow_gid' => '',
'deny_cid' => '',
'deny_gid' => '',
'guid' => '5',
],
[
'id' => 12,
'uri-id' => 6,
'uri' => '6',
'visible' => 1,
'contact-id' => 44,
'author-id' => 44,
'owner-id' => 42,
'causer-id' => 44,
'uid' => 0,
'verb' => 'http://activitystrea.ms/schema/1.0/post',
'unseen' => 0,
'parent' => 12,
'parent-uri-id' => 6,
'parent-uri' => '6',
'thr-parent-id' => 6,
'thr-parent' => '6',
'private' => Item::PUBLIC,
'gravity' => GRAVITY_PARENT,
'author-link' => 'http://localhost/profile/othercontact',
'wall' => 0,
'starred' => 0,
'origin' => 0,
'guid' => '6',
'author-id' => 44,
'owner-id' => 44,
'causer-id' => 44,
'contact-id' => 44,
'network' => Protocol::DFRN,
'starred' => 0,
'origin' => 0,
],
],
'notify' => [

View file

@ -770,3 +770,50 @@ function update_1399()
return Update::SUCCESS;
}
function update_1400()
{
if (!DBA::e("INSERT IGNORE INTO `post` (`uri-id`, `parent-uri-id`, `thr-parent-id`, `owner-id`, `author-id`, `network`,
`created`, `received`, `edited`, `gravity`, `causer-id`, `post-type`, `vid`, `private`, `visible`, `deleted`, `global`)
SELECT `uri-id`, `parent-uri-id`, `thr-parent-id`, `owner-id`, `author-id`, `network`, `created`, `received`, `edited`,
`gravity`, `causer-id`, `post-type`, `vid`, `private`, `visible`, `deleted`, `global` FROM `item`")) {
return Update::FAILED;
}
if (!DBA::e("UPDATE `post-user` INNER JOIN `item` ON `item`.`uri-id` = `post-user`.`uri-id` AND `item`.`uid` = `post-user`.`uid`
INNER JOIN `event` ON `item`.`event-id` = `event`.`id` AND `event`.`id` != 0
SET `post-user`.`event-id` = `item`.`event-id`")) {
return Update::FAILED;
}
if (!DBA::e("UPDATE `post-user` INNER JOIN `item` ON `item`.`uri-id` = `post-user`.`uri-id` AND `item`.`uid` = `post-user`.`uid`
SET `post-user`.`wall` = `item`.`wall`, `post-user`.`parent-uri-id` = `item`.`parent-uri-id`,
`post-user`.`thr-parent-id` = `item`.`thr-parent-id`,
`post-user`.`created` = `item`.`created`, `post-user`.`edited` = `item`.`edited`,
`post-user`.`received` = `item`.`received`, `post-user`.`gravity` = `item`.`gravity`,
`post-user`.`network` = `item`.`network`, `post-user`.`owner-id` = `item`.`owner-id`,
`post-user`.`author-id` = `item`.`author-id`, `post-user`.`causer-id` = `item`.`causer-id`,
`post-user`.`post-type` = `item`.`post-type`, `post-user`.`vid` = `item`.`vid`,
`post-user`.`private` = `item`.`private`, `post-user`.`global` = `item`.`global`,
`post-user`.`visible` = `item`.`visible`, `post-user`.`deleted` = `item`.`deleted`")) {
return Update::FAILED;
}
if (!DBA::e("INSERT IGNORE INTO `post-thread-user` (`uri-id`, `owner-id`, `author-id`, `causer-id`, `network`,
`created`, `received`, `changed`, `commented`, `uid`, `wall`, `contact-id`, `unseen`, `hidden`, `origin`, `psid`, `post-user-id`)
SELECT `uri-id`, `owner-id`, `author-id`, `causer-id`, `network`, `created`, `received`, `received`, `received`,
`uid`, `wall`, `contact-id`, `unseen`, `hidden`, `origin`, `psid`, `id`
FROM `post-user` WHERE `gravity` = 0 AND NOT EXISTS(SELECT `uri-id` FROM `post-thread-user` WHERE `post-user-id` = `post-user`.id)")) {
return Update::FAILED;
}
if (!DBA::e("UPDATE `post-thread-user` INNER JOIN `post-thread` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
SET `post-thread-user`.`owner-id` = `post-thread`.`owner-id`, `post-thread-user`.`author-id` = `post-thread`.`author-id`,
`post-thread-user`.`causer-id` = `post-thread`.`causer-id`, `post-thread-user`.`network` = `post-thread`.`network`,
`post-thread-user`.`created` = `post-thread`.`created`, `post-thread-user`.`received` = `post-thread`.`received`,
`post-thread-user`.`changed` = `post-thread`.`changed`, `post-thread-user`.`commented` = `post-thread`.`commented`")) {
return Update::FAILED;
}
return Update::SUCCESS;
}