Merge remote-tracking branch 'upstream/2019.09-rc' into contact-dba

This commit is contained in:
Michael Vogel 2019-08-29 04:14:01 +02:00
commit 40a7d6eb42
12 changed files with 13098 additions and 22 deletions

View file

@ -1,6 +1,6 @@
Version 2019.09-dev (UNRELEASED)
Friendica Core:
Update to the translations (DE, FR, NL) [translation teams]
Update to the translations (DE, FR, JA, NL) [translation teams]
Update to the themes (frio, vier) [JeroenED, MrPetovan, tobiasd, vinzv]
Update to the documentation [guzzisti, vinzv]
Enhanced the log output of the background process [annando]
@ -39,7 +39,7 @@ Version 2019.09-dev (UNRELEASED)
Added fetching of postings via URL to interact with public postings [annando]
Friendica Addons:
Update to the translation (DE, FR, NL SV) [translation teams]
Update to the translation (DE, FR, JA, NL SV) [translation teams]
General code cleanup [nupplaphil, Quix0r]
twitter:
Enhanced handling of multi image postings [annando]

View file

@ -677,6 +677,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
'guid' => ($preview ? 'Q0' : $item['guid']),
'network' => $item['network'],
'network_name' => ContactSelector::networkToName($item['network'], $item['author-link']),
'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item),

View file

@ -71,6 +71,39 @@ class ContactSelector
return $o;
}
/**
* @param string $profile Profile URL
* @return string Server URL
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function getServerURLForProfile($profile)
{
$server_url = '';
// Fetch the server url from the contact table
$contact = DBA::selectFirst('contact', ['baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($profile)]);
if (DBA::isResult($contact) && !empty($contact['baseurl'])) {
$server_url = Strings::normaliseLink($contact['baseurl']);
}
if (empty($server_url)) {
// Fetch the server url from the gcontact table
$gcontact = DBA::selectFirst('gcontact', ['server_url'], ['nurl' => Strings::normaliseLink($profile)]);
if (!empty($gcontact) && !empty($gcontact['server_url'])) {
$server_url = Strings::normaliseLink($gcontact['server_url']);
}
}
if (empty($server_url)) {
// Create the server url out of the profile url
$parts = parse_url($profile);
unset($parts['path']);
$server_url = Strings::normaliseLink(Network::unparseURL($parts));
}
return $server_url;
}
/**
* @param string $network network
* @param string $profile optional, default empty
@ -106,16 +139,7 @@ class ContactSelector
$networkname = str_replace($search, $replace, $network);
if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) {
// Create the server url out of the profile url
$parts = parse_url($profile);
unset($parts['path']);
$server_url = [Strings::normaliseLink(Network::unparseURL($parts))];
// Fetch the server url
$gcontact = DBA::selectFirst('gcontact', ['server_url'], ['nurl' => Strings::normaliseLink($profile)]);
if (!empty($gcontact) && !empty($gcontact['server_url'])) {
$server_url[] = Strings::normaliseLink($gcontact['server_url']);
}
$server_url = self::getServerURLForProfile($profile);
// Now query the GServer for the platform name
$gserver = DBA::selectFirst('gserver', ['platform', 'network'], ['nurl' => $server_url]);
@ -140,6 +164,58 @@ class ContactSelector
return $networkname;
}
/**
* @param string $network network
* @param string $profile optional, default empty
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function networkToIcon($network, $profile = "")
{
$nets = [
Protocol::DFRN => 'friendica',
Protocol::OSTATUS => 'gnu-social', // There is no generic OStatus icon
Protocol::FEED => 'rss',
Protocol::MAIL => 'file-text-o', /// @todo
Protocol::DIASPORA => 'diaspora',
Protocol::ZOT => 'hubzilla',
Protocol::LINKEDIN => 'linkedin',
Protocol::XMPP => 'xmpp',
Protocol::MYSPACE => 'file-text-o', /// @todo
Protocol::GPLUS => 'google-plus',
Protocol::PUMPIO => 'file-text-o', /// @todo
Protocol::TWITTER => 'twitter',
Protocol::DIASPORA2 => 'diaspora',
Protocol::STATUSNET => 'gnu-social',
Protocol::ACTIVITYPUB => 'activitypub',
Protocol::PNUT => 'file-text-o', /// @todo
];
$platform_icons = ['diaspora' => 'diaspora', 'friendica' => 'friendica', 'friendika' => 'friendica',
'GNU Social' => 'gnu-social', 'gnusocial' => 'gnu-social', 'hubzilla' => 'hubzilla',
'mastodon' => 'mastodon', 'peertube' => 'peertube', 'pixelfed' => 'pixelfed',
'pleroma' => 'pleroma', 'red' => 'hubzilla', 'redmatrix' => 'hubzilla',
'socialhome' => 'social-home', 'wordpress' => 'wordpress'];
$search = array_keys($nets);
$replace = array_values($nets);
$network_icon = str_replace($search, $replace, $network);
if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) {
$server_url = self::getServerURLForProfile($profile);
// Now query the GServer for the platform name
$gserver = DBA::selectFirst('gserver', ['platform'], ['nurl' => $server_url]);
if (DBA::isResult($gserver) && !empty($gserver['platform'])) {
$network_icon = $platform_icons[strtolower($gserver['platform'])] ?? $network_icon;
}
}
return $network_icon;
}
/**
* @param string $current optional, default empty
* @param string $suffix optionsl, default empty

View file

@ -120,7 +120,15 @@ class BBCode extends BaseObject
*/
public static function getAttachmentData($body)
{
$data = [];
$data = [
'type' => '',
'text' => '',
'after' => '',
'image' => null,
'url' => '',
'title' => '',
'description' => '',
];
if (!preg_match("/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/ism", $body, $match)) {
return self::getOldAttachmentData($body);

View file

@ -4,6 +4,7 @@ namespace Friendica\Database;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\System;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use mysqli;
@ -126,7 +127,7 @@ class Database
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->connected = true;
} catch (PDOException $e) {
/// @TODO At least log exception, don't ignore it!
$this->connected = false;
}
}
@ -484,6 +485,10 @@ class Database
// We are having an own error logging in the function "e"
$called_from_e = ($called_from['function'] == 'e');
if (!isset($this->connection)) {
throw new InternalServerErrorException('The Connection is empty, although connected is set true.');
}
switch ($this->driver) {
case 'pdo':
// If there are no arguments we use "query"

View file

@ -1898,13 +1898,19 @@ class Contact extends BaseObject
/**
* @brief Helper function for "updateFromProbe". Updates personal and public contact
*
* @param array $contact The personal contact entry
* @param array $fields The fields that are updated
* @param integer $id contact id
* @param integer $uid user id
* @param string $url The profile URL of the contact
* @param array $fields The fields that are updated
*
* @throws \Exception
*/
private static function updateContact($id, $uid, $url, array $fields)
{
DBA::update('contact', $fields, ['id' => $id]);
if (!DBA::update('contact', $fields, ['id' => $id])) {
Logger::info('Couldn\'t update contact.', ['id' => $id, 'fields' => $fields]);
return;
}
// Search for duplicated contacts and get rid of them
if (self::handleDuplicates(Strings::normaliseLink($url), $uid, $id) || ($uid != 0)) {
@ -1917,6 +1923,11 @@ class Contact extends BaseObject
// Archive or unarchive the contact. We only need to do this for the public contact.
// The archive/unarchive function will update the personal contacts by themselves.
$contact = DBA::selectFirst('contact', [], ['id' => $id]);
if (!DBA::isResult($contact)) {
Logger::info('Couldn\'t select contact for archival.', ['id' => $id]);
return;
}
if (!empty($fields['success_update'])) {
self::unmarkForArchival($contact);
} elseif (!empty($fields['failure_update'])) {

View file

@ -426,6 +426,7 @@ class Post extends BaseObject
'edited' => $edited,
'network' => $item["network"],
'network_name' => ContactSelector::networkToName($item['network'], $item['author-link']),
'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
'received' => $item['received'],
'commented' => $item['commented'],
'created_date' => $item['created'],

View file

@ -4,12 +4,12 @@
*/
namespace Friendica\Util;
use ASN_BASE;
use ASNValue;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\System;
use ASN_BASE;
use ASNValue;
/**
* @brief Crypto class
@ -209,8 +209,10 @@ class Crypto
$r = ASN_BASE::parseASNString($x);
$m = Strings::base64UrlDecode($r[0]->asnData[1]->asnData[0]->asnData[0]->asnData);
$e = Strings::base64UrlDecode($r[0]->asnData[1]->asnData[0]->asnData[1]->asnData);
if (isset($r[0])) {
$m = Strings::base64UrlDecode($r[0]->asnData[1]->asnData[0]->asnData[0]->asnData);
$e = Strings::base64UrlDecode($r[0]->asnData[1]->asnData[0]->asnData[1]->asnData);
}
}
/**

10588
view/lang/ja/messages.po Normal file

File diff suppressed because it is too large Load diff

2377
view/lang/ja/strings.php Normal file

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,11 @@
{{* Put additional actions in a top-right dropdown menu *}}
<ul class="nav nav-pills preferences">
{{if $item.network_icon != ""}}
<li><span class="wall-item-network"><i class="fa fa-{{$item.network_icon}}" title="{{$item.network_name}}" aria-hidden="true"></i></span></li>
{{else}}
<li><span class="wall-item-network" title="{{$item.app}}">{{$item.network_name}}</span></li>
{{/if}}
{{if $item.plink || $item.star || $item.drop.dropping || $item.edpost || $item.subthread}}
<li class="dropdown">

View file

@ -84,8 +84,11 @@ as the value of $top_child_total (this is done at the end of this file)
{{* Put addional actions in a top-right dropdown menu *}}
<ul class="nav nav-pills preferences">
{{if $item.network_icon != ""}}
<li><span class="wall-item-network"><i class="fa fa-{{$item.network_icon}}" title="{{$item.network_name}}" aria-hidden="true"></i></span></li>
{{else}}
<li><span class="wall-item-network" title="{{$item.app}}">{{$item.network_name}}</span></li>
{{/if}}
{{if $item.plink || $item.drop.dropping || $item.edpost || $item.ignore || $item.tagger || $item.star || $item.filer || $item.subthread}}
<li class="dropdown">
<button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" id="dropdownMenuTools-{{$item.id}}" aria-haspopup="true" aria-expanded="false"><i class="fa fa-angle-down" aria-hidden="true"></i></button>