mirror of
https://github.com/friendica/friendica
synced 2024-12-23 03:21:30 +01:00
Fix noscrape publishing and pulling, added header
This commit is contained in:
parent
5419d1d426
commit
fe07dc828b
16 changed files with 36 additions and 28 deletions
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2021.06-rc (Siberian Iris)
|
-- Friendica 2021.06-rc (Siberian Iris)
|
||||||
-- DB_UPDATE_VERSION 1422
|
-- DB_UPDATE_VERSION 1423
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,6 +120,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
||||||
`photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
|
`photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
|
||||||
`thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
|
`thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
|
||||||
`micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
|
`micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
|
||||||
|
`header` varchar(255) COMMENT 'Header picture',
|
||||||
`site-pubkey` text COMMENT '',
|
`site-pubkey` text COMMENT '',
|
||||||
`issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
|
@ -343,6 +344,7 @@ CREATE TABLE IF NOT EXISTS `apcontact` (
|
||||||
`name` varchar(255) COMMENT '',
|
`name` varchar(255) COMMENT '',
|
||||||
`about` text COMMENT '',
|
`about` text COMMENT '',
|
||||||
`photo` varchar(255) COMMENT '',
|
`photo` varchar(255) COMMENT '',
|
||||||
|
`header` varchar(255) COMMENT 'Header picture',
|
||||||
`addr` varchar(255) COMMENT '',
|
`addr` varchar(255) COMMENT '',
|
||||||
`alias` varchar(255) COMMENT '',
|
`alias` varchar(255) COMMENT '',
|
||||||
`pubkey` text COMMENT '',
|
`pubkey` text COMMENT '',
|
||||||
|
@ -2256,6 +2258,7 @@ CREATE VIEW `owner-view` AS SELECT
|
||||||
`contact`.`photo` AS `photo`,
|
`contact`.`photo` AS `photo`,
|
||||||
`contact`.`thumb` AS `thumb`,
|
`contact`.`thumb` AS `thumb`,
|
||||||
`contact`.`micro` AS `micro`,
|
`contact`.`micro` AS `micro`,
|
||||||
|
`contact`.`header` AS `header`,
|
||||||
`contact`.`site-pubkey` AS `site-pubkey`,
|
`contact`.`site-pubkey` AS `site-pubkey`,
|
||||||
`contact`.`issued-id` AS `issued-id`,
|
`contact`.`issued-id` AS `issued-id`,
|
||||||
`contact`.`dfrn-id` AS `dfrn-id`,
|
`contact`.`dfrn-id` AS `dfrn-id`,
|
||||||
|
|
|
@ -21,6 +21,7 @@ Fields
|
||||||
| name | | varchar(255) | YES | | NULL | |
|
| name | | varchar(255) | YES | | NULL | |
|
||||||
| about | | text | YES | | NULL | |
|
| about | | text | YES | | NULL | |
|
||||||
| photo | | varchar(255) | YES | | NULL | |
|
| photo | | varchar(255) | YES | | NULL | |
|
||||||
|
| header | Header picture | varchar(255) | YES | | NULL | |
|
||||||
| addr | | varchar(255) | YES | | NULL | |
|
| addr | | varchar(255) | YES | | NULL | |
|
||||||
| alias | | varchar(255) | YES | | NULL | |
|
| alias | | varchar(255) | YES | | NULL | |
|
||||||
| pubkey | | text | YES | | NULL | |
|
| pubkey | | text | YES | | NULL | |
|
||||||
|
|
|
@ -30,6 +30,7 @@ Fields
|
||||||
| photo | Link to the profile photo of the contact | varchar(255) | YES | | | |
|
| photo | Link to the profile photo of the contact | varchar(255) | YES | | | |
|
||||||
| thumb | Link to the profile photo (thumb size) | varchar(255) | YES | | | |
|
| thumb | Link to the profile photo (thumb size) | varchar(255) | YES | | | |
|
||||||
| micro | Link to the profile photo (micro size) | varchar(255) | YES | | | |
|
| micro | Link to the profile photo (micro size) | varchar(255) | YES | | | |
|
||||||
|
| header | Header picture | varchar(255) | YES | | NULL | |
|
||||||
| site-pubkey | | text | YES | | NULL | |
|
| site-pubkey | | text | YES | | NULL | |
|
||||||
| issued-id | | varchar(255) | NO | | | |
|
| issued-id | | varchar(255) | NO | | | |
|
||||||
| dfrn-id | | varchar(255) | NO | | | |
|
| dfrn-id | | varchar(255) | NO | | | |
|
||||||
|
|
|
@ -67,7 +67,7 @@ function cal_init(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->profile = Profile::getByNickname($nick, $a->profile_uid);
|
$a->profile = Profile::getByNickname($nick);
|
||||||
if (empty($a->profile)) {
|
if (empty($a->profile)) {
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ function photos_init(App $a) {
|
||||||
$a->profile_uid = $user['uid'];
|
$a->profile_uid = $user['uid'];
|
||||||
$is_owner = (local_user() && (local_user() == $a->profile_uid));
|
$is_owner = (local_user() && (local_user() == $a->profile_uid));
|
||||||
|
|
||||||
$profile = Profile::getByNickname($nick, $a->profile_uid);
|
$profile = Profile::getByNickname($nick);
|
||||||
|
|
||||||
$account_type = Contact::getAccountType($profile);
|
$account_type = Contact::getAccountType($profile);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ function videos_init(App $a)
|
||||||
$a->data['user'] = $user[0];
|
$a->data['user'] = $user[0];
|
||||||
$a->profile_uid = $user[0]['uid'];
|
$a->profile_uid = $user[0]['uid'];
|
||||||
|
|
||||||
$profile = Profile::getByNickname($nick, $a->profile_uid);
|
$profile = Profile::getByNickname($nick);
|
||||||
|
|
||||||
$account_type = Contact::getAccountType($profile);
|
$account_type = Contact::getAccountType($profile);
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,8 @@ class Update
|
||||||
if ($sendMail) {
|
if ($sendMail) {
|
||||||
self::updateSuccessful($stored, $current);
|
self::updateSuccessful($stored, $current);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Logger::warning('Update lock could not be acquired');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,11 @@ class APContact
|
||||||
$apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
|
$apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$apcontact['header'] = JsonLD::fetchElement($compacted, 'as:image', '@id');
|
||||||
|
if (is_array($apcontact['header']) || !empty($compacted['as:image']['as:url']['@id'])) {
|
||||||
|
$apcontact['header'] = JsonLD::fetchElement($compacted['as:image'], 'as:url', '@id');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($apcontact['alias'])) {
|
if (empty($apcontact['alias'])) {
|
||||||
$apcontact['alias'] = JsonLD::fetchElement($compacted, 'as:url', '@id');
|
$apcontact['alias'] = JsonLD::fetchElement($compacted, 'as:url', '@id');
|
||||||
if (is_array($apcontact['alias'])) {
|
if (is_array($apcontact['alias'])) {
|
||||||
|
|
|
@ -1103,7 +1103,7 @@ class Contact
|
||||||
if (($uid == 0) && (empty($data['network']) || ($data['network'] == Protocol::PHANTOM))) {
|
if (($uid == 0) && (empty($data['network']) || ($data['network'] == Protocol::PHANTOM))) {
|
||||||
// Fetch data for the public contact via the first found personal contact
|
// Fetch data for the public contact via the first found personal contact
|
||||||
/// @todo Check if this case can happen at all (possibly with mail accounts?)
|
/// @todo Check if this case can happen at all (possibly with mail accounts?)
|
||||||
$fields = ['name', 'nick', 'url', 'addr', 'alias', 'avatar', 'contact-type',
|
$fields = ['name', 'nick', 'url', 'addr', 'alias', 'avatar', 'header', 'contact-type',
|
||||||
'keywords', 'location', 'about', 'unsearchable', 'batch', 'notify', 'poll',
|
'keywords', 'location', 'about', 'unsearchable', 'batch', 'notify', 'poll',
|
||||||
'request', 'confirm', 'poco', 'subscribe', 'network', 'baseurl', 'gsid'];
|
'request', 'confirm', 'poco', 'subscribe', 'network', 'baseurl', 'gsid'];
|
||||||
|
|
||||||
|
@ -1949,8 +1949,8 @@ class Contact
|
||||||
// These fields aren't updated by this routine:
|
// These fields aren't updated by this routine:
|
||||||
// 'xmpp', 'sensitive'
|
// 'xmpp', 'sensitive'
|
||||||
|
|
||||||
$fields = ['uid', 'avatar', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe', 'manually-approve',
|
$fields = ['uid', 'avatar', 'header', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
|
||||||
'unsearchable', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
|
'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'];
|
||||||
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
|
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
|
|
|
@ -283,24 +283,17 @@ class Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all profile data of a local user
|
* Get the profile for the given nick name
|
||||||
*
|
|
||||||
* If the viewer is an authenticated remote viewer, the profile displayed is the
|
|
||||||
* one that has been configured for his/her viewing in the Contact manager.
|
|
||||||
* Passing a non-zero profile ID can also allow a preview of a selected profile
|
|
||||||
* by the owner
|
|
||||||
*
|
*
|
||||||
* Includes all available profile data
|
* Includes all available profile data
|
||||||
*
|
*
|
||||||
* @param string $nickname nick
|
* @param string $nickname nick
|
||||||
* @param int $uid uid
|
|
||||||
* @param int $profile_id ID of the profile
|
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getByNickname($nickname, $uid = 0)
|
public static function getByNickname($nickname)
|
||||||
{
|
{
|
||||||
$profile = DBA::selectFirst('owner-view', [], ['nickname' => $nickname, 'uid' => $uid]);
|
$profile = DBA::selectFirst('owner-view', [], ['nickname' => $nickname]);
|
||||||
return $profile;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class NoScrape extends BaseModule
|
||||||
System::jsonError(403, 'Authentication required');
|
System::jsonError(403, 'Authentication required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = Profile::getByNickname($which, local_user());
|
$profile = Profile::getByNickname($which);
|
||||||
|
|
||||||
if (empty($profile['uid'])) {
|
if (empty($profile['uid'])) {
|
||||||
System::jsonError(404, 'Profile not found');
|
System::jsonError(404, 'Profile not found');
|
||||||
|
|
|
@ -87,8 +87,8 @@ class Probe
|
||||||
*/
|
*/
|
||||||
private static function rearrangeData($data)
|
private static function rearrangeData($data)
|
||||||
{
|
{
|
||||||
$fields = ["name", "nick", "guid", "url", "addr", "alias", "photo", "account-type",
|
$fields = ["name", "nick", "guid", "url", "addr", "alias", "photo", "header",
|
||||||
"community", "keywords", "location", "about", "hide",
|
"account-type", "community", "keywords", "location", "about", "hide",
|
||||||
"batch", "notify", "poll", "request", "confirm", "subscribe", "poco",
|
"batch", "notify", "poll", "request", "confirm", "subscribe", "poco",
|
||||||
"following", "followers", "inbox", "outbox", "sharedinbox",
|
"following", "followers", "inbox", "outbox", "sharedinbox",
|
||||||
"priority", "network", "pubkey", "manually-approve", "baseurl", "gsid"];
|
"priority", "network", "pubkey", "manually-approve", "baseurl", "gsid"];
|
||||||
|
@ -1016,18 +1016,18 @@ class Probe
|
||||||
$curlResult = DI::httpRequest()->get($noscrape_url);
|
$curlResult = DI::httpRequest()->get($noscrape_url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return [];
|
return $data;
|
||||||
}
|
}
|
||||||
$content = $curlResult->getBody();
|
$content = $curlResult->getBody();
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
Logger::info('Empty body', ['url' => $noscrape_url]);
|
Logger::info('Empty body', ['url' => $noscrape_url]);
|
||||||
return [];
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = json_decode($content, true);
|
$json = json_decode($content, true);
|
||||||
if (!is_array($json)) {
|
if (!is_array($json)) {
|
||||||
Logger::info('No json data', ['url' => $noscrape_url]);
|
Logger::info('No json data', ['url' => $noscrape_url]);
|
||||||
return [];
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($json["fn"])) {
|
if (!empty($json["fn"])) {
|
||||||
|
@ -2222,7 +2222,7 @@ class Probe
|
||||||
|
|
||||||
$data = ['name' => $profile['name'], 'nick' => $profile['nick'], 'guid' => $approfile['diaspora:guid'] ?? '',
|
$data = ['name' => $profile['name'], 'nick' => $profile['nick'], 'guid' => $approfile['diaspora:guid'] ?? '',
|
||||||
'url' => $profile['url'], 'addr' => $profile['addr'], 'alias' => $profile['alias'],
|
'url' => $profile['url'], 'addr' => $profile['addr'], 'alias' => $profile['alias'],
|
||||||
'photo' => $profile['photo'], 'account-type' => $profile['contact-type'],
|
'photo' => $profile['photo'], 'header' => $profile['header'], 'account-type' => $profile['contact-type'],
|
||||||
'community' => ($profile['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY),
|
'community' => ($profile['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY),
|
||||||
'keywords' => $profile['keywords'], 'location' => $profile['location'], 'about' => $profile['about'],
|
'keywords' => $profile['keywords'], 'location' => $profile['location'], 'about' => $profile['about'],
|
||||||
'hide' => !$profile['net-publish'], 'batch' => '', 'notify' => $profile['notify'],
|
'hide' => !$profile['net-publish'], 'batch' => '', 'notify' => $profile['notify'],
|
||||||
|
|
|
@ -114,9 +114,8 @@ class Account extends BaseDataTransferObject
|
||||||
$this->url = $publicContact['url'];
|
$this->url = $publicContact['url'];
|
||||||
$this->avatar = $userContact['avatar'] ?? $publicContact['avatar'];
|
$this->avatar = $userContact['avatar'] ?? $publicContact['avatar'];
|
||||||
$this->avatar_static = $userContact['avatar'] ?? $publicContact['avatar'];
|
$this->avatar_static = $userContact['avatar'] ?? $publicContact['avatar'];
|
||||||
// No header picture in Friendica
|
$this->header = ($userContact['header'] ?? $publicContact['header']) ?? '';
|
||||||
$this->header = '';
|
$this->header_static = ($userContact['header'] ?? $publicContact['header']) ?? '';
|
||||||
$this->header_static = '';
|
|
||||||
$this->followers_count = $apcontact['followers_count'] ?? 0;
|
$this->followers_count = $apcontact['followers_count'] ?? 0;
|
||||||
$this->following_count = $apcontact['following_count'] ?? 0;
|
$this->following_count = $apcontact['following_count'] ?? 0;
|
||||||
$this->statuses_count = $apcontact['statuses_count'] ?? 0;
|
$this->statuses_count = $apcontact['statuses_count'] ?? 0;
|
||||||
|
|
|
@ -151,6 +151,7 @@ class ActivityPub
|
||||||
$profile['outbox'] = $apcontact['outbox'];
|
$profile['outbox'] = $apcontact['outbox'];
|
||||||
$profile['sharedinbox'] = $apcontact['sharedinbox'];
|
$profile['sharedinbox'] = $apcontact['sharedinbox'];
|
||||||
$profile['photo'] = $apcontact['photo'];
|
$profile['photo'] = $apcontact['photo'];
|
||||||
|
$profile['header'] = $apcontact['header'];
|
||||||
$profile['account-type'] = self::getAccountType($apcontact);
|
$profile['account-type'] = self::getAccountType($apcontact);
|
||||||
$profile['community'] = ($profile['account-type'] == User::ACCOUNT_TYPE_COMMUNITY);
|
$profile['community'] = ($profile['account-type'] == User::ACCOUNT_TYPE_COMMUNITY);
|
||||||
// $profile['keywords']
|
// $profile['keywords']
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1422);
|
define('DB_UPDATE_VERSION', 1423);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -177,6 +177,7 @@ return [
|
||||||
"photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"],
|
"photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"],
|
||||||
"thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"],
|
"thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"],
|
||||||
"micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"],
|
"micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"],
|
||||||
|
"header" => ["type" => "varchar(255)", "comment" => "Header picture"],
|
||||||
"site-pubkey" => ["type" => "text", "comment" => ""],
|
"site-pubkey" => ["type" => "text", "comment" => ""],
|
||||||
"issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
"dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
|
@ -404,6 +405,7 @@ return [
|
||||||
"name" => ["type" => "varchar(255)", "comment" => ""],
|
"name" => ["type" => "varchar(255)", "comment" => ""],
|
||||||
"about" => ["type" => "text", "comment" => ""],
|
"about" => ["type" => "text", "comment" => ""],
|
||||||
"photo" => ["type" => "varchar(255)", "comment" => ""],
|
"photo" => ["type" => "varchar(255)", "comment" => ""],
|
||||||
|
"header" => ["type" => "varchar(255)", "comment" => "Header picture"],
|
||||||
"addr" => ["type" => "varchar(255)", "comment" => ""],
|
"addr" => ["type" => "varchar(255)", "comment" => ""],
|
||||||
"alias" => ["type" => "varchar(255)", "comment" => ""],
|
"alias" => ["type" => "varchar(255)", "comment" => ""],
|
||||||
"pubkey" => ["type" => "text", "comment" => ""],
|
"pubkey" => ["type" => "text", "comment" => ""],
|
||||||
|
|
|
@ -723,6 +723,7 @@
|
||||||
"photo" => ["contact", "photo"],
|
"photo" => ["contact", "photo"],
|
||||||
"thumb" => ["contact", "thumb"],
|
"thumb" => ["contact", "thumb"],
|
||||||
"micro" => ["contact", "micro"],
|
"micro" => ["contact", "micro"],
|
||||||
|
"header" => ["contact", "header"],
|
||||||
"site-pubkey" => ["contact", "site-pubkey"],
|
"site-pubkey" => ["contact", "site-pubkey"],
|
||||||
"issued-id" => ["contact", "issued-id"],
|
"issued-id" => ["contact", "issued-id"],
|
||||||
"dfrn-id" => ["contact", "dfrn-id"],
|
"dfrn-id" => ["contact", "dfrn-id"],
|
||||||
|
|
Loading…
Reference in a new issue