The post-media table now works with the "attach" field as well

This commit is contained in:
Michael 2020-10-31 13:26:08 +00:00
parent e5c145e73c
commit 8485c8c357
7 changed files with 131 additions and 22 deletions

View file

@ -968,6 +968,14 @@ class Item
while ($item = DBA::fetch($items)) {
if (empty($content_fields['verb']) || !in_array($content_fields['verb'], self::ACTIVITIES)) {
if (!empty($content_fields['body'])) {
$content_fields['raw-body'] = trim($content_fields['raw-body'] ?? $content_fields['body']);
// Remove all media attachments from the body and store them in the post-media table
$content_fields['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $content_fields['raw-body']);
$content_fields['raw-body'] = self::setHashtags($content_fields['raw-body']);
}
self::updateContent($content_fields, ['uri-id' => $item['uri-id']]);
if (empty($item['icid'])) {
@ -994,6 +1002,10 @@ class Item
}
}
if (!empty($fields['attach'])) {
Post\Media::insertFromAttachment($item['uri-id'], $fields['attach']);
}
Post\DeliveryData::update($item['uri-id'], $delivery_data);
self::updateThread($item['id']);
@ -1826,6 +1838,10 @@ class Item
// Check for hashtags in the body and repair or add hashtag links
$item['body'] = self::setHashtags($item['body']);
if (!empty($item['attach'])) {
Post\Media::insertFromAttachment($item['uri-id'], $item['attach']);
}
// Fill the cache field
self::putInCache($item);