Merge pull request #11869 from annando/issue-11853
Issue 11853/11867: Fix reshare of public posts
This commit is contained in:
commit
45729f0107
|
@ -161,7 +161,7 @@ class Avatar
|
||||||
$dirpath .= $part . '/';
|
$dirpath .= $part . '/';
|
||||||
|
|
||||||
if (!file_exists($dirpath)) {
|
if (!file_exists($dirpath)) {
|
||||||
if (!mkdir($dirpath, $dir_perm)) {
|
if (!@mkdir($dirpath, $dir_perm)) {
|
||||||
Logger::warning('Directory could not be created', ['directory' => $dirpath]);
|
Logger::warning('Directory could not be created', ['directory' => $dirpath]);
|
||||||
}
|
}
|
||||||
} elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) {
|
} elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ class Database
|
||||||
protected $connection;
|
protected $connection;
|
||||||
protected $driver = '';
|
protected $driver = '';
|
||||||
protected $pdo_emulate_prepares = false;
|
protected $pdo_emulate_prepares = false;
|
||||||
private $error = false;
|
private $error = '';
|
||||||
private $errorno = 0;
|
private $errorno = 0;
|
||||||
private $affected_rows = 0;
|
private $affected_rows = 0;
|
||||||
protected $in_transaction = false;
|
protected $in_transaction = false;
|
||||||
|
@ -558,8 +558,8 @@ class Database
|
||||||
if (count($args) == 0) {
|
if (count($args) == 0) {
|
||||||
if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) {
|
if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) {
|
||||||
$errorInfo = $this->connection->errorInfo();
|
$errorInfo = $this->connection->errorInfo();
|
||||||
$this->error = $errorInfo[2];
|
$this->error = (string)$errorInfo[2];
|
||||||
$this->errorno = (int) $errorInfo[1];
|
$this->errorno = (int)$errorInfo[1];
|
||||||
$retval = false;
|
$retval = false;
|
||||||
$is_error = true;
|
$is_error = true;
|
||||||
break;
|
break;
|
||||||
|
@ -571,8 +571,8 @@ class Database
|
||||||
/** @var $stmt mysqli_stmt|PDOStatement */
|
/** @var $stmt mysqli_stmt|PDOStatement */
|
||||||
if (!$stmt = $this->connection->prepare($sql)) {
|
if (!$stmt = $this->connection->prepare($sql)) {
|
||||||
$errorInfo = $this->connection->errorInfo();
|
$errorInfo = $this->connection->errorInfo();
|
||||||
$this->error = $errorInfo[2];
|
$this->error = (string)$errorInfo[2];
|
||||||
$this->errorno = (int) $errorInfo[1];
|
$this->errorno = (int)$errorInfo[1];
|
||||||
$retval = false;
|
$retval = false;
|
||||||
$is_error = true;
|
$is_error = true;
|
||||||
break;
|
break;
|
||||||
|
@ -591,8 +591,8 @@ class Database
|
||||||
|
|
||||||
if (!$stmt->execute()) {
|
if (!$stmt->execute()) {
|
||||||
$errorInfo = $stmt->errorInfo();
|
$errorInfo = $stmt->errorInfo();
|
||||||
$this->error = $errorInfo[2];
|
$this->error = (string)$errorInfo[2];
|
||||||
$this->errorno = (int) $errorInfo[1];
|
$this->errorno = (int)$errorInfo[1];
|
||||||
$retval = false;
|
$retval = false;
|
||||||
$is_error = true;
|
$is_error = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -610,8 +610,8 @@ class Database
|
||||||
if (!$can_be_prepared || (count($args) == 0)) {
|
if (!$can_be_prepared || (count($args) == 0)) {
|
||||||
$retval = $this->connection->query($this->replaceParameters($sql, $args));
|
$retval = $this->connection->query($this->replaceParameters($sql, $args));
|
||||||
if ($this->connection->errno) {
|
if ($this->connection->errno) {
|
||||||
$this->error = $this->connection->error;
|
$this->error = (string)$this->connection->error;
|
||||||
$this->errorno = $this->connection->errno;
|
$this->errorno = (int)$this->connection->errno;
|
||||||
$retval = false;
|
$retval = false;
|
||||||
$is_error = true;
|
$is_error = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -627,8 +627,8 @@ class Database
|
||||||
$stmt = $this->connection->stmt_init();
|
$stmt = $this->connection->stmt_init();
|
||||||
|
|
||||||
if (!$stmt->prepare($sql)) {
|
if (!$stmt->prepare($sql)) {
|
||||||
$this->error = $stmt->error;
|
$this->error = (string)$stmt->error;
|
||||||
$this->errorno = $stmt->errno;
|
$this->errorno = (int)$stmt->errno;
|
||||||
$retval = false;
|
$retval = false;
|
||||||
$is_error = true;
|
$is_error = true;
|
||||||
break;
|
break;
|
||||||
|
@ -658,8 +658,8 @@ class Database
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$stmt->execute()) {
|
if (!$stmt->execute()) {
|
||||||
$this->error = $this->connection->error;
|
$this->error = (string)$this->connection->error;
|
||||||
$this->errorno = $this->connection->errno;
|
$this->errorno = (int)$this->connection->errno;
|
||||||
$retval = false;
|
$retval = false;
|
||||||
$is_error = true;
|
$is_error = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -726,8 +726,8 @@ class Database
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->error = $error;
|
$this->error = (string)$error;
|
||||||
$this->errorno = (int) $errorno;
|
$this->errorno = (int)$errorno;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->profiler->stopRecording();
|
$this->profiler->stopRecording();
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Model;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -125,6 +126,7 @@ class FContact
|
||||||
|
|
||||||
$condition = ['url' => $arr['url'], 'network' => $arr['network']];
|
$condition = ['url' => $arr['url'], 'network' => $arr['network']];
|
||||||
|
|
||||||
|
$fields = DI::dbaDefinition()->truncateFieldsForTable('fcontact', $fields);
|
||||||
DBA::update('fcontact', $fields, $condition, true);
|
DBA::update('fcontact', $fields, $condition, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ use Friendica\Model\Tag;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Post;
|
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
|
@ -2545,7 +2544,7 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the current logged in user's public contact
|
// Retrieve the current logged in user's public contact
|
||||||
$author_id = Contact::getIdForURL($owner['url']);
|
$author_id = Contact::getPublicIdByUserId($uid);
|
||||||
if (empty($author_id)) {
|
if (empty($author_id)) {
|
||||||
Logger::info('Empty public contact');
|
Logger::info('Empty public contact');
|
||||||
return false;
|
return false;
|
||||||
|
@ -2652,7 +2651,7 @@ class Item
|
||||||
$new_item = [
|
$new_item = [
|
||||||
'guid' => System::createUUID(),
|
'guid' => System::createUUID(),
|
||||||
'uri' => self::newURI(),
|
'uri' => self::newURI(),
|
||||||
'uid' => $item['uid'],
|
'uid' => $uid,
|
||||||
'contact-id' => $owner['id'],
|
'contact-id' => $owner['id'],
|
||||||
'wall' => $item['wall'],
|
'wall' => $item['wall'],
|
||||||
'origin' => 1,
|
'origin' => 1,
|
||||||
|
@ -2680,17 +2679,13 @@ class Item
|
||||||
$new_item['diaspora_signed_text'] = json_encode($signed);
|
$new_item['diaspora_signed_text'] = json_encode($signed);
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_item_id = self::insert($new_item);
|
self::insert($new_item, true);
|
||||||
|
|
||||||
// If the parent item isn't visible then set it to visible
|
// If the parent item isn't visible then set it to visible
|
||||||
|
// @todo Check if this is still needed
|
||||||
if (!$item['visible']) {
|
if (!$item['visible']) {
|
||||||
self::update(['visible' => true], ['id' => $item['id']]);
|
self::update(['visible' => true], ['id' => $item['id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_item['id'] = $new_item_id;
|
|
||||||
|
|
||||||
Hook::callAll('post_local_end', $new_item);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,9 @@ class Activity extends BaseModule
|
||||||
$itemId = $this->parameters['id'];
|
$itemId = $this->parameters['id'];
|
||||||
|
|
||||||
if (in_array($verb, ['announce', 'unannounce'])) {
|
if (in_array($verb, ['announce', 'unannounce'])) {
|
||||||
$item = Post::selectFirst(['network', 'uri-id', 'uid'], ['id' => $itemId]);
|
$item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [local_user(), 0]]);
|
||||||
if ($item['network'] == Protocol::DIASPORA) {
|
if ($item['network'] == Protocol::DIASPORA) {
|
||||||
Diaspora::performReshare($item['uri-id'], $item['uid']);
|
Diaspora::performReshare($item['uri-id'], local_user());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ class Processor
|
||||||
{
|
{
|
||||||
$item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity', 'post-type', 'private'], ['uri' => $activity['id']]);
|
$item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity', 'post-type', 'private'], ['uri' => $activity['id']]);
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
Logger::warning('No existing item, item will be created', ['uri' => $activity['id']]);
|
Logger::notice('No existing item, item will be created', ['uri' => $activity['id']]);
|
||||||
$item = self::createItem($activity, false);
|
$item = self::createItem($activity, false);
|
||||||
if (empty($item)) {
|
if (empty($item)) {
|
||||||
Queue::remove($activity);
|
Queue::remove($activity);
|
||||||
|
|
|
@ -1040,17 +1040,17 @@ class ParseUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'description');
|
$content = JsonLD::fetchElement($jsonld, 'description');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['text'] = trim($content);
|
$jsonldinfo['text'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'image');
|
$content = JsonLD::fetchElement($jsonld, 'image');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['image'] = trim($content);
|
$jsonldinfo['image'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'thumbnailUrl');
|
$content = JsonLD::fetchElement($jsonld, 'thumbnailUrl');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['image'] = trim($content);
|
$jsonldinfo['image'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,22 +1075,22 @@ class ParseUrl
|
||||||
$jsonldinfo = [];
|
$jsonldinfo = [];
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'name');
|
$content = JsonLD::fetchElement($jsonld, 'name');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_name'] = trim($content);
|
$jsonldinfo['publisher_name'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'description');
|
$content = JsonLD::fetchElement($jsonld, 'description');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_description'] = trim($content);
|
$jsonldinfo['publisher_description'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'url');
|
$content = JsonLD::fetchElement($jsonld, 'url');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_url'] = trim($content);
|
$jsonldinfo['publisher_url'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'thumbnailUrl');
|
$content = JsonLD::fetchElement($jsonld, 'thumbnailUrl');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['image'] = trim($content);
|
$jsonldinfo['image'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,32 +1114,32 @@ class ParseUrl
|
||||||
$jsonldinfo = [];
|
$jsonldinfo = [];
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'name');
|
$content = JsonLD::fetchElement($jsonld, 'name');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_name'] = trim($content);
|
$jsonldinfo['publisher_name'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'description');
|
$content = JsonLD::fetchElement($jsonld, 'description');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_description'] = trim($content);
|
$jsonldinfo['publisher_description'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'url');
|
$content = JsonLD::fetchElement($jsonld, 'url');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_url'] = trim($content);
|
$jsonldinfo['publisher_url'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'logo', 'url', '@type', 'ImageObject');
|
$content = JsonLD::fetchElement($jsonld, 'logo', 'url', '@type', 'ImageObject');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_img'] = trim($content);
|
$jsonldinfo['publisher_img'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'brand', 'name', '@type', 'Organization');
|
$content = JsonLD::fetchElement($jsonld, 'brand', 'name', '@type', 'Organization');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_name'] = trim($content);
|
$jsonldinfo['publisher_name'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'brand', 'url', '@type', 'Organization');
|
$content = JsonLD::fetchElement($jsonld, 'brand', 'url', '@type', 'Organization');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['publisher_url'] = trim($content);
|
$jsonldinfo['publisher_url'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,12 +1161,12 @@ class ParseUrl
|
||||||
$jsonldinfo = [];
|
$jsonldinfo = [];
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'name');
|
$content = JsonLD::fetchElement($jsonld, 'name');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['author_name'] = trim($content);
|
$jsonldinfo['author_name'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'description');
|
$content = JsonLD::fetchElement($jsonld, 'description');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['author_description'] = trim($content);
|
$jsonldinfo['author_description'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1176,7 +1176,7 @@ class ParseUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'url');
|
$content = JsonLD::fetchElement($jsonld, 'url');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$jsonldinfo['author_url'] = trim($content);
|
$jsonldinfo['author_url'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,22 +1207,22 @@ class ParseUrl
|
||||||
$media = [];
|
$media = [];
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'caption');
|
$content = JsonLD::fetchElement($jsonld, 'caption');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['caption'] = trim($content);
|
$media['caption'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'url');
|
$content = JsonLD::fetchElement($jsonld, 'url');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['url'] = trim($content);
|
$media['url'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'mainEntityOfPage');
|
$content = JsonLD::fetchElement($jsonld, 'mainEntityOfPage');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['main'] = Strings::compareLink($content, $siteinfo['url']);
|
$media['main'] = Strings::compareLink($content, $siteinfo['url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'description');
|
$content = JsonLD::fetchElement($jsonld, 'description');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['description'] = trim($content);
|
$media['description'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1232,27 +1232,27 @@ class ParseUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'contentUrl');
|
$content = JsonLD::fetchElement($jsonld, 'contentUrl');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['content'] = trim($content);
|
$media['content'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'embedUrl');
|
$content = JsonLD::fetchElement($jsonld, 'embedUrl');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['embed'] = trim($content);
|
$media['embed'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'height');
|
$content = JsonLD::fetchElement($jsonld, 'height');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['height'] = trim($content);
|
$media['height'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'width');
|
$content = JsonLD::fetchElement($jsonld, 'width');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['width'] = trim($content);
|
$media['width'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = JsonLD::fetchElement($jsonld, 'image');
|
$content = JsonLD::fetchElement($jsonld, 'image');
|
||||||
if (!empty($content)) {
|
if (!empty($content) && is_string($content)) {
|
||||||
$media['image'] = trim($content);
|
$media['image'] = trim($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue