-- ------------------------------------------
-- Friendica 2021.03-rc (Red Hot Poker)
--- DB_UPDATE_VERSION 1412
+-- DB_UPDATE_VERSION 1413
-- ------------------------------------------
`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 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, ...)',
+ `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
`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 '',
`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 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, ...)',
+ `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, image, article, ...)',
+ `post-reason` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Reason why the post arrived at the user',
`vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
`private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
`global` boolean NOT NULL DEFAULT '0' COMMENT '',
`post-user`.`received` AS `received`,
`post-thread-user`.`changed` AS `changed`,
`post-user`.`post-type` AS `post-type`,
+ `post-user`.`post-reason` AS `post-reason`,
`post-user`.`private` AS `private`,
`post-thread-user`.`pubmail` AS `pubmail`,
`post-user`.`visible` AS `visible`,
`post-thread-user`.`received` AS `received`,
`post-thread-user`.`changed` AS `changed`,
`post-user`.`post-type` AS `post-type`,
+ `post-user`.`post-reason` AS `post-reason`,
`post-user`.`private` AS `private`,
`post-thread-user`.`pubmail` AS `pubmail`,
`post-thread-user`.`ignored` AS `ignored`,
while ($row = Post::fetch($thread_items)) {
if (!empty($activity)) {
if (($row['gravity'] == GRAVITY_PARENT)) {
- $row['post-type'] = Item::PT_ANNOUNCEMENT;
+ $row['post-reason'] = Item::PR_ANNOUNCEMENT;
$row = array_merge($row, $activity);
$contact = Contact::getById($activity['causer-id'], ['url', 'name', 'thumb']);
$row['causer-link'] = $contact['url'];
$name = $row['causer-contact-type'] == Contact::TYPE_RELAY ? $row['causer-link'] : $row['causer-name'];
- switch ($row['post-type']) {
- case Item::PT_TO:
+ switch ($row['post-reason']) {
+ case Item::PR_TO:
$row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'to')];
break;
- case Item::PT_CC:
+ case Item::PR_CC:
$row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'cc')];
break;
- case Item::PT_BTO:
+ case Item::PR_BTO:
$row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'bto')];
break;
- case Item::PT_BCC:
+ case Item::PR_BCC:
$row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'bcc')];
break;
- case Item::PT_FOLLOWER:
+ case Item::PR_FOLLOWER:
$row['direction'] = ['direction' => 6, 'title' => DI::l10n()->t('You are following %s.', $row['author-name'])];
break;
- case Item::PT_TAG:
+ case Item::PR_TAG:
$row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')];
break;
- case Item::PT_ANNOUNCEMENT:
+ case Item::PR_ANNOUNCEMENT:
if (!empty($row['causer-id']) && DI::pConfig()->get(local_user(), 'system', 'display_resharer')) {
$row['owner-id'] = $row['causer-id'];
$row['owner-link'] = $row['causer-link'];
}
$row['direction'] = ['direction' => 3, 'title' => (empty($row['causer-id']) ? DI::l10n()->t('Reshared') : DI::l10n()->t('Reshared by %s', $name))];
break;
- case Item::PT_COMMENT:
+ case Item::PR_COMMENT:
$row['direction'] = ['direction' => 5, 'title' => DI::l10n()->t('%s is participating in this thread.', $row['author-name'])];
break;
- case Item::PT_STORED:
+ case Item::PR_STORED:
$row['direction'] = ['direction' => 8, 'title' => DI::l10n()->t('Stored')];
break;
- case Item::PT_GLOBAL:
+ case Item::PR_GLOBAL:
$row['direction'] = ['direction' => 9, 'title' => DI::l10n()->t('Global')];
break;
- case Item::PT_RELAY:
+ case Item::PR_RELAY:
$row['direction'] = ['direction' => 10, 'title' => (empty($row['causer-id']) ? DI::l10n()->t('Relayed') : DI::l10n()->t('Relayed by %s.', $name))];
break;
- case Item::PT_FETCHED:
+ case Item::PR_FETCHED:
$row['direction'] = ['direction' => 2, 'title' => (empty($row['causer-id']) ? DI::l10n()->t('Fetched') : DI::l10n()->t('Fetched because of %s', $name))];
break;
}
$condition[0] .= " AND NOT `author-hidden`";
}
- $thread_items = Post::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['pinned', 'contact-uid', 'gravity', 'post-type']), $condition, $params);
+ $thread_items = Post::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['pinned', 'contact-uid', 'gravity', 'post-reason']), $condition, $params);
$comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false, $activity);
$item_arr['visible'] = 1;
$item_arr['verb'] = Activity::POST;
$item_arr['object-type'] = Activity\ObjectType::EVENT;
+ $item_arr['post-type'] = Item::PT_EVENT;
$item_arr['origin'] = $event['cid'] === 0 ? 1 : 0;
$item_arr['body'] = self::getBBCode($event);
$item_arr['event-id'] = $event['id'];
const PT_VIDEO = 18;
const PT_DOCUMENT = 19;
const PT_EVENT = 32;
- const PT_TAG = 64;
- const PT_TO = 65;
- const PT_CC = 66;
- const PT_BTO = 67;
- const PT_BCC = 68;
- const PT_FOLLOWER = 69;
- const PT_ANNOUNCEMENT = 70;
- const PT_COMMENT = 71;
- const PT_STORED = 72;
- const PT_GLOBAL = 73;
- const PT_RELAY = 74;
- const PT_FETCHED = 75;
const PT_PERSONAL_NOTE = 128;
+ // Posting reasons (Why had a post been stored for a user?)
+ const PR_NONE = 0;
+ const PR_TAG = 64;
+ const PR_TO = 65;
+ const PR_CC = 66;
+ const PR_BTO = 67;
+ const PR_BCC = 68;
+ const PR_FOLLOWER = 69;
+ const PR_ANNOUNCEMENT = 70;
+ const PR_COMMENT = 71;
+ const PR_STORED = 72;
+ const PR_GLOBAL = 73;
+ const PR_RELAY = 74;
+ const PR_FETCHED = 75;
+
// Field list that is used to display the items
const DISPLAY_FIELDLIST = [
'uid', 'id', 'parent', 'guid', 'network', 'gravity',
const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid',
'parent-guid', 'received', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
'private', 'title', 'body', 'raw-body', 'location', 'coord', 'app',
- 'inform', 'deleted', 'extid', 'post-type', 'gravity',
+ 'inform', 'deleted', 'extid', 'post-type', 'post-reason', 'gravity',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'author-id', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid',
'signed_text', 'network', 'wall', 'contact-id', 'plink', 'forum_mode', 'origin',
'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',
+ 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type', 'post-reason',
'private', 'pubmail', 'visible', 'starred',
'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network',
'title', 'content-warning', 'body', 'location', 'coord', 'app',
return 0;
}
+ if (!isset($item['post-type'])) {
+ $item['post-type'] = empty($item['title']) ? self::PT_NOTE : self::PT_ARTICLE;
+ }
+
$item['wall'] = intval($item['wall'] ?? 0);
$item['extid'] = trim($item['extid'] ?? '');
$item['author-name'] = trim($item['author-name'] ?? '');
$item['coord'] = trim($item['coord'] ?? '');
$item['visible'] = (isset($item['visible']) ? intval($item['visible']) : 1);
$item['deleted'] = 0;
- $item['post-type'] = ($item['post-type'] ?? '') ?: self::PT_ARTICLE;
$item['verb'] = trim($item['verb'] ?? '');
$item['object-type'] = trim($item['object-type'] ?? '');
$item['object'] = trim($item['object'] ?? '');
$actor = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
if (!$item['origin'] && ($item['uid'] != 0) && Contact::isSharing($actor, $item['uid'])) {
- $item['post-type'] = self::PT_FOLLOWER;
+ $item['post-reason'] = self::PR_FOLLOWER;
}
// Ensure that there is an avatar cache
*/
private static function setOwnerforResharedItem(array $item)
{
- $parent = Post::selectFirst(['id', 'causer-id', 'owner-id', 'author-id', 'author-link', 'origin', 'post-type'],
+ $parent = Post::selectFirst(['id', 'causer-id', 'owner-id', 'author-id', 'author-link', 'origin', 'post-reason'],
['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
if (!DBA::isResult($parent)) {
Logger::error('Parent not found', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
}
if ($author['contact-type'] != Contact::TYPE_COMMUNITY) {
- if ($parent['post-type'] == self::PT_ANNOUNCEMENT) {
+ if ($parent['post-reason'] == self::PR_ANNOUNCEMENT) {
Logger::info('The parent is already marked as announced: quit', ['causer' => $parent['causer-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
return;
}
Logger::info('The resharer is no forum: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
return;
}
- self::update(['post-type' => self::PT_ANNOUNCEMENT, 'causer-id' => $item['author-id']], ['id' => $parent['id']]);
- Logger::info('Set announcement post-type', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
+ self::update(['post-reason' => self::PR_ANNOUNCEMENT, 'causer-id' => $item['author-id']], ['id' => $parent['id']]);
+ Logger::info('Set announcement post-reason', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
return;
}
if (Contact::isSharing($item['author-id'], $uid)) {
$fields = [];
} else {
- $fields = ['post-type' => self::PT_TAG];
+ $fields = ['post-reason' => self::PR_TAG];
}
$stored = self::storeForUserByUriId($item['uri-id'], $uid, $fields);
return 0;
}
- $item['post-type'] = self::PT_STORED;
+ $item['post-reason'] = self::PR_STORED;
$item = array_merge($item, $fields);
unset($item['starred']);
unset($item['postopts']);
unset($item['inform']);
- unset($item['post-type']);
+ unset($item['post-reason']);
if ($item['uri-id'] == $item['parent-uri-id']) {
$item['contact-id'] = $item['owner-id'];
} else {
unset($item['starred']);
unset($item['postopts']);
unset($item['inform']);
- unset($item['post-type']);
+ unset($item['post-reason']);
$item['contact-id'] = Contact::getIdForURL($item['author-link']);
$public_shadow = self::insert($item, false, true);
// Only expire posts, not photos and photo comments
- if (!$expire_photos && (!empty($item['resource-id']) || ($item['post-type'] == self::PT_IMAGE))) {
+ if (!$expire_photos && !empty($item['resource-id'])) {
continue;
} elseif (!$expire_starred && intval($item['starred'])) {
continue;
if (($filetype == 'video')) {
/// @todo Move the template to /content as well
- $leading .= Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [
+ $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [
'$video' => [
'id' => $item['author-id'],
'src' => $the_url,
'mime' => $mime,
],
]);
+ if ($item['post-type'] == Item::PT_VIDEO) {
+ $leading .= $media;
+ } else {
+ $trailing .= $media;
+ }
} elseif ($filetype == 'audio') {
- $leading .= Renderer::replaceMacros(Renderer::getMarkupTemplate('content/audio.tpl'), [
+ $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/audio.tpl'), [
'$audio' => [
'id' => $item['author-id'],
'src' => $the_url,
'mime' => $mime,
],
]);
+ if ($item['post-type'] == Item::PT_AUDIO) {
+ $leading .= $media;
+ } else {
+ $trailing .= $media;
+ }
} else {
$title = Strings::escapeHtml(trim(($attachment['description'] ?? '') ?: $attachment['url']));
// image is the preview/thumbnail URL
if (!empty($attach['image'])) {
- $trailing .= '[url=' . $attach['url'] . ']';
+ $media = '[url=' . $attach['url'] . ']';
$attach['url'] = $attach['image'];
+ } else {
+ $media = '';
}
if (empty($attach['name'])) {
- $trailing .= '[img]' . $attach['url'] . '[/img]';
+ $media .= '[img]' . $attach['url'] . '[/img]';
} else {
- $trailing .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]';
+ $media .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]';
}
if (!empty($attach['image'])) {
- $trailing .= '[/url]';
+ $media .= '[/url]';
}
+
+ if ($item['post-type'] == Item::PT_IMAGE) {
+ $leading .= $media;
+ } else {
+ $trailing .= $media;
+ }
} elseif ($filetype == 'audio') {
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
continue 2;
}
- $leading .= '[audio]' . $attach['url'] . "[/audio]\n";
+ if ($item['post-type'] == Item::PT_AUDIO) {
+ $leading .= '[audio]' . $attach['url'] . "[/audio]\n";
+ } else {
+ $trailing .= '[audio]' . $attach['url'] . "[/audio]\n";
+ }
} elseif ($filetype == 'video') {
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
continue 2;
}
- $leading .= '[video]' . $attach['url'] . "[/video]\n";
+ if ($item['post-type'] == Item::PT_VIDEO) {
+ $leading .= '[video]' . $attach['url'] . "[/video]\n";
+ } else {
+ $trailing .= '[video]' . $attach['url'] . "[/video]\n";
+ }
}
}
}
*/
public static function updateItem($activity)
{
- $item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity'], ['uri' => $activity['id']]);
+ $item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity', 'post-type'], ['uri' => $activity['id']]);
if (!DBA::isResult($item)) {
Logger::warning('No existing item, item will be created', ['uri' => $activity['id']]);
$item = self::createItem($activity);
$item['direction'] = Conversation::RELAY;
}
+ if ($activity['object_type'] == 'as:Article') {
+ $item['post-type'] = Item::PT_ARTICLE;
+ } elseif ($activity['object_type'] == 'as:Audio') {
+ $item['post-type'] = Item::PT_AUDIO;
+ } elseif ($activity['object_type'] == 'as:Document') {
+ $item['post-type'] = Item::PT_DOCUMENT;
+ } elseif ($activity['object_type'] == 'as:Event') {
+ $item['post-type'] = Item::PT_EVENT;
+ } elseif ($activity['object_type'] == 'as:Image') {
+ $item['post-type'] = Item::PT_IMAGE;
+ } elseif ($activity['object_type'] == 'as:Page') {
+ $item['post-type'] = Item::PT_PAGE;
+ } elseif ($activity['object_type'] == 'as:Video') {
+ $item['post-type'] = Item::PT_VIDEO;
+ } else {
+ $item['post-type'] = Item::PT_NOTE;
+ }
+
$item['isForum'] = false;
if (!empty($activity['thread-completion'])) {
$item['verb'] = $verb;
$item['thr-parent'] = $activity['object_id'];
$item['gravity'] = GRAVITY_ACTIVITY;
+ unset($item['post-type']);
$item['object-type'] = Activity\ObjectType::NOTE;
$item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
$type = $activity['reception_type'][$receiver] ?? Receiver::TARGET_UNKNOWN;
switch($type) {
case Receiver::TARGET_TO:
- $item['post-type'] = Item::PT_TO;
+ $item['post-reason'] = Item::PR_TO;
break;
case Receiver::TARGET_CC:
- $item['post-type'] = Item::PT_CC;
+ $item['post-reason'] = Item::PR_CC;
break;
case Receiver::TARGET_BTO:
- $item['post-type'] = Item::PT_BTO;
+ $item['post-reason'] = Item::PR_BTO;
break;
case Receiver::TARGET_BCC:
- $item['post-type'] = Item::PT_BCC;
+ $item['post-reason'] = Item::PR_BCC;
break;
case Receiver::TARGET_FOLLOWER:
- $item['post-type'] = Item::PT_FOLLOWER;
+ $item['post-reason'] = Item::PR_FOLLOWER;
break;
case Receiver::TARGET_ANSWER:
- $item['post-type'] = Item::PT_COMMENT;
+ $item['post-reason'] = Item::PR_COMMENT;
break;
case Receiver::TARGET_GLOBAL:
- $item['post-type'] = Item::PT_GLOBAL;
+ $item['post-reason'] = Item::PR_GLOBAL;
break;
default:
- $item['post-type'] = Item::PT_ARTICLE;
+ $item['post-reason'] = Item::PR_NONE;
}
if (!empty($activity['from-relay'])) {
- $item['post-type'] = Item::PT_RELAY;
+ $item['post-reason'] = Item::PR_RELAY;
} elseif (!empty($activity['thread-completion'])) {
- $item['post-type'] = Item::PT_FETCHED;
+ $item['post-reason'] = Item::PR_FETCHED;
}
if ($item['isForum'] ?? false) {
return;
}
- $item['post-type'] = Item::PT_ANNOUNCEMENT;
+ $item['post-reason'] = Item::PR_ANNOUNCEMENT;
ActivityPub\Processor::postItem($object_data, $item);
$announce_object_data = self::processObject($activity);
$item["title"] = XML::getFirstNodeValue($xpath, "atom:title/text()", $entry);
+ if (!empty($item["title"])) {
+ $item["post-type"] = Item::PT_ARTICLE;
+ } else {
+ $item["post-type"] = Item::PT_NOTE;
+ }
+
$item["created"] = XML::getFirstNodeValue($xpath, "atom:published/text()", $entry);
$item["body"] = XML::getFirstNodeValue($xpath, "dfrn:env/text()", $entry);
if (in_array($entrytype, [DFRN::REPLY, DFRN::REPLY_RC])) {
// Will be overwritten for sharing accounts in Item::insert
- if (empty($item['post-type']) && ($entrytype == DFRN::REPLY)) {
- $item['post-type'] = Item::PT_COMMENT;
+ if (empty($item['post-reason']) && ($entrytype == DFRN::REPLY)) {
+ $item['post-reason'] = Item::PR_COMMENT;
}
$posted_id = Item::insert($item);
$header["direction"] = $direction;
if ($direction === Conversation::RELAY) {
- $header['post-type'] = Item::PT_RELAY;
+ $header['post-reason'] = Item::PR_RELAY;
}
// Update the contact table if the data has changed
// Will be overwritten for sharing accounts in Item::insert
if ($fetched) {
- $datarray["post-type"] = Item::PT_FETCHED;
+ $datarray["post-reason"] = Item::PR_FETCHED;
} elseif ($datarray["uid"] == 0) {
- $datarray["post-type"] = Item::PT_GLOBAL;
+ $datarray["post-reason"] = Item::PR_GLOBAL;
} else {
- $datarray["post-type"] = Item::PT_COMMENT;
+ $datarray["post-reason"] = Item::PR_COMMENT;
}
$datarray["guid"] = $guid;
$datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
$datarray["object-type"] = Activity\ObjectType::COMMENT;
+ $datarray["post-type"] = Item::PT_NOTE;
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
$datarray["source"] = $xml;
}
$datarray["object-type"] = Activity\ObjectType::IMAGE;
+ $datarray["post-type"] = Item::PT_IMAGE;
} else {
$datarray["object-type"] = Activity\ObjectType::NOTE;
+ $datarray["post-type"] = Item::PT_NOTE;
// Add OEmbed and other information to the body
if (!self::isHubzilla($contact["url"])) {
$datarray["direction"] = $fetched ? Conversation::PULL : Conversation::PUSH;
if ($fetched) {
- $datarray["post-type"] = Item::PT_FETCHED;
+ $datarray["post-reason"] = Item::PR_FETCHED;
} elseif ($datarray["uid"] == 0) {
- $datarray["post-type"] = Item::PT_GLOBAL;
+ $datarray["post-reason"] = Item::PR_GLOBAL;
}
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
$header["private"] = Item::PUBLIC;
$header["verb"] = Activity::POST;
$header["object-type"] = Activity\ObjectType::NOTE;
+ $header["post-type"] = Item::PT_ARTICLE;
$header["contact-id"] = $contact["id"] ?? 0;
}
}
+ if (empty($item['title'])) {
+ $item['post-type'] = Item::PT_NOTE;
+ }
+
Logger::info('Stored feed', ['item' => $item]);
$notify = Item::isRemoteSelf($contact, $item);
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 `post-user`
- WHERE (`origin` OR `event-id` != 0 OR `post-type` IN (?, ?)) AND `parent-uri-id` = `post-thread`.`uri-id`)
+ 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`))",
- $expire_days, Item::PT_PERSONAL_NOTE, Item::PT_IMAGE]);
+ $expire_days, Item::PT_PERSONAL_NOTE]);
Logger::notice('Start deleting expired threads');
$affected_count = 0;
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1412);
+ define('DB_UPDATE_VERSION', 1413);
}
return [
"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", "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, ...)"],
+ "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, image, article, ...)"],
"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" => ""],
"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", "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, ...)"],
+ "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, image, article, ...)"],
+ "post-reason" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Reason why the post arrived at the user"],
"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" => ""],
"received" => ["post-user", "received"],
"changed" => ["post-thread-user", "changed"],
"post-type" => ["post-user", "post-type"],
+ "post-reason" => ["post-user", "post-reason"],
"private" => ["post-user", "private"],
"pubmail" => ["post-thread-user", "pubmail"],
"visible" => ["post-user", "visible"],
"received" => ["post-thread-user", "received"],
"changed" => ["post-thread-user", "changed"],
"post-type" => ["post-user", "post-type"],
+ "post-reason" => ["post-user", "post-reason"],
"private" => ["post-user", "private"],
"pubmail" => ["post-thread-user", "pubmail"],
"ignored" => ["post-thread-user", "ignored"],
continue 2;
}
DBA::update('workerqueue', ['parameter' => json_encode($parameters)], ['id' => $task['id']]);
+
+ return Update::SUCCESS;
}
}
if (!DBA::e("UPDATE `post-thread-user` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
return Update::FAILED;
}
+
+ return Update::SUCCESS;
+}
+
+function update_1413()
+{
+ if (!DBA::e("UPDATE `post-user` SET `post-reason` = `post-type` WHERE `post-type` >= 64 and `post-type` <= 75")) {
+ return Update::FAILED;
+ }
}