mirror of
https://github.com/friendica/friendica
synced 2025-04-27 08:30:10 +00:00
Merge branch 'master' into develop
This commit is contained in:
commit
27d94023ee
70 changed files with 27138 additions and 26508 deletions
|
@ -173,20 +173,18 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function terminateFriendship(array $user, array $contact)
|
||||
{
|
||||
if ($contact['network'] === NETWORK_OSTATUS) {
|
||||
if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) {
|
||||
// create an unfollow slap
|
||||
$item = [];
|
||||
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
|
||||
$item['follow'] = $contact["url"];
|
||||
$slap = OStatus::salmon($item, $user);
|
||||
|
||||
if ((x($contact, 'notify')) && (strlen($contact['notify']))) {
|
||||
if (!empty($contact['notify'])) {
|
||||
Salmon::slapper($user, $contact['notify'], $slap);
|
||||
}
|
||||
} elseif ($contact['network'] === NETWORK_DIASPORA) {
|
||||
} elseif ($contact['network'] == NETWORK_DIASPORA) {
|
||||
Diaspora::sendUnshare($user, $contact);
|
||||
} elseif ($contact['network'] === NETWORK_DFRN) {
|
||||
DFRN::deliver($user, $contact, 'placeholder', 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +514,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
$sparkle = false;
|
||||
if ($contact['network'] === NETWORK_DFRN) {
|
||||
if (($contact['network'] === NETWORK_DFRN) && !$contact['self']) {
|
||||
$sparkle = true;
|
||||
$profile_link = System::baseUrl() . '/redir/' . $contact['id'];
|
||||
} else {
|
||||
|
@ -533,18 +531,21 @@ class Contact extends BaseObject
|
|||
$profile_link = $profile_link . '?url=profile';
|
||||
}
|
||||
|
||||
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
|
||||
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA]) && !$contact['self']) {
|
||||
$pm_url = System::baseUrl() . '/message/new/' . $contact['id'];
|
||||
}
|
||||
|
||||
if ($contact['network'] == NETWORK_DFRN) {
|
||||
if (($contact['network'] == NETWORK_DFRN) && !$contact['self']) {
|
||||
$poke_link = System::baseUrl() . '/poke/?f=&c=' . $contact['id'];
|
||||
}
|
||||
|
||||
$contact_url = System::baseUrl() . '/contacts/' . $contact['id'];
|
||||
|
||||
$posts_link = System::baseUrl() . '/contacts/' . $contact['id'] . '/posts';
|
||||
$contact_drop_link = System::baseUrl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
|
||||
|
||||
if (!$contact['self']) {
|
||||
$contact_drop_link = System::baseUrl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu array:
|
||||
|
@ -1168,7 +1169,26 @@ class Contact extends BaseObject
|
|||
return result;
|
||||
}
|
||||
|
||||
if ($ret['network'] === NETWORK_DFRN) {
|
||||
// check if we already have a contact
|
||||
// the poll url is more reliable than the profile url, as we may have
|
||||
// indirect links or webfinger links
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' AND NOT `pending` LIMIT 1",
|
||||
intval($uid),
|
||||
dbesc($ret['poll']),
|
||||
dbesc(normalise_link($ret['poll'])),
|
||||
dbesc($ret['network'])
|
||||
);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' AND NOT `pending` LIMIT 1",
|
||||
intval($uid),
|
||||
dbesc(normalise_link($url)),
|
||||
dbesc($ret['network'])
|
||||
);
|
||||
}
|
||||
|
||||
if (($ret['network'] === NETWORK_DFRN) && !DBM::is_result($r)) {
|
||||
if ($interactive) {
|
||||
if (strlen($a->path)) {
|
||||
$myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
|
||||
|
@ -1180,7 +1200,7 @@ class Contact extends BaseObject
|
|||
|
||||
// NOTREACHED
|
||||
}
|
||||
} elseif (Config::get('system', 'dfrn_only')) {
|
||||
} elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != NETWORK_DFRN)) {
|
||||
$result['message'] = L10n::t('This site is not configured to allow communications with other networks.') . EOL;
|
||||
$result['message'] != L10n::t('No compatible communication protocols or feeds were discovered.') . EOL;
|
||||
return $result;
|
||||
|
@ -1230,25 +1250,6 @@ class Contact extends BaseObject
|
|||
$writeable = 1;
|
||||
}
|
||||
|
||||
// check if we already have a contact
|
||||
// the poll url is more reliable than the profile url, as we may have
|
||||
// indirect links or webfinger links
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' LIMIT 1",
|
||||
intval($uid),
|
||||
dbesc($ret['poll']),
|
||||
dbesc(normalise_link($ret['poll'])),
|
||||
dbesc($ret['network'])
|
||||
);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
|
||||
intval($uid),
|
||||
dbesc(normalise_link($url)),
|
||||
dbesc($ret['network'])
|
||||
);
|
||||
}
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
// update contact
|
||||
$new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
|
||||
|
@ -1309,16 +1310,16 @@ class Contact extends BaseObject
|
|||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
|
||||
if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) {
|
||||
// create a follow slap
|
||||
$item = [];
|
||||
$item['verb'] = ACTIVITY_FOLLOW;
|
||||
$item['follow'] = $contact["url"];
|
||||
$slap = OStatus::salmon($item, $r[0]);
|
||||
Salmon::slapper($r[0], $contact['notify'], $slap);
|
||||
}
|
||||
|
||||
if ($contact['network'] == NETWORK_DIASPORA) {
|
||||
if (!empty($contact['notify'])) {
|
||||
Salmon::slapper($r[0], $contact['notify'], $slap);
|
||||
}
|
||||
} elseif ($contact['network'] == NETWORK_DIASPORA) {
|
||||
$ret = Diaspora::sendShare($a->user, $contact);
|
||||
logger('share returns: ' . $ret);
|
||||
}
|
||||
|
@ -1377,7 +1378,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
if (is_array($contact)) {
|
||||
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|
||||
if (($contact['rel'] == CONTACT_IS_SHARING)
|
||||
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
dba::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
|
||||
['id' => $contact['id'], 'uid' => $importer['uid']]);
|
||||
|
|
|
@ -36,56 +36,53 @@ class GContact
|
|||
*/
|
||||
public static function searchByName($search, $mode = '')
|
||||
{
|
||||
if ($search) {
|
||||
// check supported networks
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
$diaspora = NETWORK_DIASPORA;
|
||||
} else {
|
||||
$diaspora = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
$ostatus = NETWORK_OSTATUS;
|
||||
} else {
|
||||
$ostatus = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
// check if we search only communities or every contact
|
||||
if ($mode === "community") {
|
||||
$extra_sql = " AND `community`";
|
||||
} else {
|
||||
$extra_sql = "";
|
||||
}
|
||||
|
||||
$search .= "%";
|
||||
|
||||
$results = q(
|
||||
"SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
|
||||
`gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community`
|
||||
FROM `gcontact`
|
||||
LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
|
||||
AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
|
||||
AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
|
||||
WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
|
||||
((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
|
||||
(`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
|
||||
(`gcontact`.`addr` LIKE '%s' OR `gcontact`.`name` LIKE '%s' OR `gcontact`.`nick` LIKE '%s') $extra_sql
|
||||
GROUP BY `gcontact`.`nurl`
|
||||
ORDER BY `gcontact`.`nurl` DESC
|
||||
LIMIT 1000",
|
||||
intval(local_user()),
|
||||
dbesc(CONTACT_IS_SHARING),
|
||||
dbesc(CONTACT_IS_FRIEND),
|
||||
dbesc(NETWORK_DFRN),
|
||||
dbesc($ostatus),
|
||||
dbesc($diaspora),
|
||||
dbesc(escape_tags($search)),
|
||||
dbesc(escape_tags($search)),
|
||||
dbesc(escape_tags($search))
|
||||
);
|
||||
|
||||
return $results;
|
||||
if (empty($search)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// check supported networks
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
$diaspora = NETWORK_DIASPORA;
|
||||
} else {
|
||||
$diaspora = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
$ostatus = NETWORK_OSTATUS;
|
||||
} else {
|
||||
$ostatus = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
// check if we search only communities or every contact
|
||||
if ($mode === "community") {
|
||||
$extra_sql = " AND `community`";
|
||||
} else {
|
||||
$extra_sql = "";
|
||||
}
|
||||
|
||||
$search .= "%";
|
||||
|
||||
$results = dba::p("SELECT `nurl` FROM `gcontact`
|
||||
WHERE NOT `hide` AND `network` IN (?, ?, ?) AND
|
||||
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
|
||||
(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
|
||||
GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000",
|
||||
NETWORK_DFRN, $ostatus, $diaspora, $search, $search, $search
|
||||
);
|
||||
|
||||
$gcontacts = [];
|
||||
while ($result = dba::fetch($results)) {
|
||||
$urlparts = parse_url($result["nurl"]);
|
||||
|
||||
// Ignore results that look strange.
|
||||
// For historic reasons the gcontact table does contain some garbage.
|
||||
if (!empty($urlparts['query']) || !empty($urlparts['fragment'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$gcontacts[] = Contact::getDetailsByURL($result["nurl"], local_user());
|
||||
}
|
||||
return $gcontacts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ use Friendica\Object\Image;
|
|||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\XML;
|
||||
use dba;
|
||||
use Text_LanguageDetect;
|
||||
|
||||
|
@ -355,6 +356,10 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($item['thr-parent'])) {
|
||||
$item['parent-uri'] = $item['thr-parent'];
|
||||
}
|
||||
|
||||
if (x($item, 'gravity')) {
|
||||
$item['gravity'] = intval($item['gravity']);
|
||||
} elseif ($item['parent-uri'] === $item['uri']) {
|
||||
|
@ -897,7 +902,11 @@ class Item extends BaseObject
|
|||
$item['uid'] = 0;
|
||||
$item['origin'] = 0;
|
||||
$item['wall'] = 0;
|
||||
$item['contact-id'] = Contact::getIdForURL($item['author-link']);
|
||||
if ($item['uri'] == $item['parent-uri']) {
|
||||
$item['contact-id'] = Contact::getIdForURL($item['owner-link']);
|
||||
} else {
|
||||
$item['contact-id'] = Contact::getIdForURL($item['author-link']);
|
||||
}
|
||||
|
||||
if (in_array($item['type'], ["net-comment", "wall-comment"])) {
|
||||
$item['type'] = 'remote-comment';
|
||||
|
@ -1264,21 +1273,23 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// now change this copy of the post to a forum head message and deliver to all the tgroup members
|
||||
$self = dba::selectFirst('contact', ['name', 'url', 'thumb'], ['uid' => $uid, 'self' => true]);
|
||||
$self = dba::selectFirst('contact', ['id', 'name', 'url', 'thumb'], ['uid' => $uid, 'self' => true]);
|
||||
if (!DBM::is_result($self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$owner_id = Contact::getIdForURL($self['url']);
|
||||
|
||||
// also reset all the privacy bits to the forum default permissions
|
||||
|
||||
$private = ($user['allow_cid'] || $user['allow_gid'] || $user['deny_cid'] || $user['deny_gid']) ? 1 : 0;
|
||||
|
||||
$forum_mode = ($prvgroup ? 2 : 1);
|
||||
|
||||
$fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode,
|
||||
'owner-name' => $self['name'], 'owner-link' => $self['url'], 'owner-avatar' => $self['thumb'],
|
||||
'private' => $private, 'allow_cid' => $user['allow_cid'], 'allow_gid' => $user['allow_gid'],
|
||||
'deny_cid' => $user['deny_cid'], 'deny_gid' => $user['deny_gid']];
|
||||
$fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode, 'contact-id' => $self['id'],
|
||||
'owner-id' => $owner_id, 'owner-name' => $self['name'], 'owner-link' => $self['url'],
|
||||
'owner-avatar' => $self['thumb'], 'private' => $private, 'allow_cid' => $user['allow_cid'],
|
||||
'allow_gid' => $user['allow_gid'], 'deny_cid' => $user['deny_cid'], 'deny_gid' => $user['deny_gid']];
|
||||
dba::update('item', $fields, ['id' => $item_id]);
|
||||
|
||||
self::updateThread($item_id);
|
||||
|
|
|
@ -395,7 +395,7 @@ class User
|
|||
throw new Exception(L10n::t('Not a valid email address.'));
|
||||
}
|
||||
|
||||
if (dba::exists('user', ['email' => $email])) {
|
||||
if (Config::get('system', 'block_extended_register', false) && dba::exists('user', ['email' => $email])) {
|
||||
throw new Exception(L10n::t('Cannot use that email.'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue