Merge remote-tracking branch 'upstream/develop' into app-user2

This commit is contained in:
Michael 2021-08-09 15:32:32 +00:00
commit 4495e83eca
36 changed files with 446 additions and 312 deletions

View file

@ -676,7 +676,7 @@ class Contact
public static function updateSelfFromUserID($uid, $update_avatar = false)
{
$fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', 'prvkey', 'pubkey',
'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable',
'xmpp', 'matrix', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable',
'photo', 'thumb', 'micro', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco', 'network'];
$self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($self)) {
@ -690,7 +690,7 @@ class Contact
}
$fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
'country-name', 'pub_keywords', 'xmpp', 'net-publish'];
'country-name', 'pub_keywords', 'xmpp', 'matrix', 'net-publish'];
$profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]);
if (!DBA::isResult($profile)) {
return false;
@ -702,7 +702,7 @@ class Contact
'avatar-date' => $self['avatar-date'], 'location' => Profile::formatLocation($profile),
'about' => $profile['about'], 'keywords' => $profile['pub_keywords'],
'contact-type' => $user['account-type'], 'prvkey' => $user['prvkey'],
'pubkey' => $user['pubkey'], 'xmpp' => $profile['xmpp'], 'network' => Protocol::DFRN];
'pubkey' => $user['pubkey'], 'xmpp' => $profile['xmpp'], 'matrix' => $profile['matrix'], 'network' => Protocol::DFRN];
// it seems as if ported accounts can have wrong values, so we make sure that now everything is fine.
$fields['url'] = DI::baseUrl() . '/profile/' . $user['nickname'];
@ -2064,11 +2064,11 @@ class Contact
*/
// These fields aren't updated by this routine:
// 'xmpp', 'sensitive'
// 'sensitive'
$fields = ['uid', 'uri-id', 'avatar', 'header', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
'manually-approve', 'unsearchable', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item'];
'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item', 'xmpp', 'matrix'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
if (!DBA::isResult($contact)) {
return false;

View file

@ -706,7 +706,7 @@ class Item
return GRAVITY_UNKNOWN; // Should not happen
}
public static function insert($item, $notify = false, $dontcache = false)
public static function insert(array $item, bool $notify = false, bool $post_local = true)
{
$orig_item = $item;
@ -931,7 +931,7 @@ class Item
$item["private"] = self::PRIVATE;
}
if ($notify) {
if ($notify && $post_local) {
$item['edit'] = false;
$item['parent'] = $parent_id;
@ -953,7 +953,7 @@ class Item
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
}
} else {
} elseif (!$notify) {
Hook::callAll('post_remote', $item);
}
@ -1141,15 +1141,13 @@ class Item
return 0;
}
if (!$dontcache) {
if ($notify) {
if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == GRAVITY_COMMENT)) {
Tag::createImplicitMentions($posted_item['uri-id'], $posted_item['thr-parent-id']);
}
Hook::callAll('post_local_end', $posted_item);
} else {
Hook::callAll('post_remote_end', $posted_item);
if ($notify) {
if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == GRAVITY_COMMENT)) {
Tag::createImplicitMentions($posted_item['uri-id'], $posted_item['thr-parent-id']);
}
Hook::callAll('post_local_end', $posted_item);
} else {
Hook::callAll('post_remote_end', $posted_item);
}
if ($posted_item['gravity'] === GRAVITY_PARENT) {
@ -1465,7 +1463,7 @@ class Item
}
}
$distributed = self::insert($item, $notify, true);
$distributed = self::insert($item, $notify);
if (!$distributed) {
Logger::info("Distributed item wasn't stored", ['uri-id' => $item['uri-id'], 'user' => $uid]);
@ -1534,7 +1532,7 @@ class Item
$item['contact-id'] = $item['author-id'];
}
$public_shadow = self::insert($item, false, true);
$public_shadow = self::insert($item);
Logger::info('Stored public shadow', ['thread' => $itemid, 'id' => $public_shadow]);
}
@ -1593,7 +1591,7 @@ class Item
unset($item['post-reason']);
$item['contact-id'] = Contact::getIdForURL($item['author-link']);
$public_shadow = self::insert($item, false, true);
$public_shadow = self::insert($item);
Logger::info('Stored public shadow', ['uri-id' => $item['uri-id'], 'id' => $public_shadow]);

View file

@ -33,19 +33,36 @@ use Friendica\Util\DateTimeFormat;
class Delayed
{
/**
* The content of the post is posted as is. Connector settings are using the default settings.
* This is used for automated scheduled posts via feeds or from the API.
*/
const PREPARED = 0;
/**
* The content is posted like a manual post. Means some processing of body will be done.
* Also it is posted with default permissions and default connector settings.
* This is used for mirrored connector posts.
*/
const UNPREPARED = 1;
/**
* Like PREPARED, but additionally the connector settings can differ.
* This is used when manually publishing scheduled posts.
*/
const PREPARED_NO_HOOK = 2;
/**
* Insert a new delayed post
*
* @param string $uri
* @param array $item
* @param integer $notify
* @param bool $unprepared
* @param string $delayed
* @param array $taglist
* @param array $attachments
* @return int ID of the created delayed post entry
* @param string $uri
* @param array $item
* @param int $notify
* @param int $preparation_mode
* @param string $delayed
* @param array $taglist
* @param array $attachments
* @return int ID of the created delayed post entry
*/
public static function add(string $uri, array $item, int $notify = 0, bool $unprepared = false, string $delayed = '', array $taglist = [], array $attachments = [])
public static function add(string $uri, array $item, int $notify = 0, int $preparation_mode = self::PREPARED, string $delayed = '', array $taglist = [], array $attachments = [])
{
if (empty($item['uid']) || self::exists($uri, $item['uid'])) {
Logger::notice('No uid or already found');
@ -63,7 +80,7 @@ class Delayed
Logger::notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]);
$wid = Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $unprepared, $uri);
$wid = Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
if (!$wid) {
return 0;
}
@ -168,21 +185,21 @@ class Delayed
/**
* Publish a delayed post
*
* @param array $item
* @param integer $notify
* @param array $taglist
* @param array $attachments
* @param bool $unprepared
* @param array $item
* @param int $notify
* @param array $taglist
* @param array $attachments
* @param int $preparation_mode
* @param string $uri
* @return bool
*/
public static function publish(array $item, int $notify = 0, array $taglist = [], array $attachments = [], bool $unprepared = false, string $uri = '')
public static function publish(array $item, int $notify = 0, array $taglist = [], array $attachments = [], int $preparation_mode = self::PREPARED, string $uri = '')
{
if (!empty($attachments)) {
$item['attachments'] = $attachments;
}
if ($unprepared) {
if ($preparation_mode == self::UNPREPARED) {
$_SESSION['authenticated'] = true;
$_SESSION['uid'] = $item['uid'];
@ -209,7 +226,8 @@ class Delayed
return $id;
}
$id = Item::insert($item, $notify);
$id = Item::insert($item, $notify, $preparation_mode == self::PREPARED);
Logger::notice('Post stored', ['id' => $id, 'uid' => $item['uid'], 'cid' => $item['contact-id']]);

View file

@ -361,6 +361,7 @@ class Profile
$homepage = !empty($profile['homepage']) ? DI::l10n()->t('Homepage:') : false;
$about = !empty($profile['about']) ? DI::l10n()->t('About:') : false;
$xmpp = !empty($profile['xmpp']) ? DI::l10n()->t('XMPP:') : false;
$matrix = !empty($profile['matrix']) ? DI::l10n()->t('Matrix:') : false;
if ((!empty($profile['hidewall']) || $block) && !Session::isAuthenticated()) {
$location = $homepage = $about = false;
@ -439,6 +440,7 @@ class Profile
$o .= Renderer::replaceMacros($tpl, [
'$profile' => $p,
'$xmpp' => $xmpp,
'$matrix' => $matrix,
'$follow' => DI::l10n()->t('Follow'),
'$follow_link' => $follow_link,
'$unfollow' => DI::l10n()->t('Unfollow'),