mirror of
https://github.com/friendica/friendica
synced 2024-11-10 09:02:53 +00:00
Merge pull request #6433 from annando/issue-6282
Issue 6282: Update the forum status of contacts
This commit is contained in:
commit
32ebfbd3e2
3 changed files with 39 additions and 6 deletions
|
@ -157,8 +157,9 @@ class APContact extends BaseObject
|
||||||
|
|
||||||
$apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted, 'w3id:publicKey', 'w3id:publicKeyPem'));
|
$apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted, 'w3id:publicKey', 'w3id:publicKeyPem'));
|
||||||
|
|
||||||
|
$manually_approve = JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
|
||||||
|
|
||||||
// To-Do
|
// To-Do
|
||||||
// manuallyApprovesFollowers
|
|
||||||
|
|
||||||
// Unhandled
|
// Unhandled
|
||||||
// @context, tag, attachment, image, nomadicLocations, signature, following, followers, featured, movedTo, liked
|
// @context, tag, attachment, image, nomadicLocations, signature, following, followers, featured, movedTo, liked
|
||||||
|
@ -197,10 +198,14 @@ class APContact extends BaseObject
|
||||||
if (is_int($contact_type)) {
|
if (is_int($contact_type)) {
|
||||||
$contact_fields['contact-type'] = $contact_type;
|
$contact_fields['contact-type'] = $contact_type;
|
||||||
|
|
||||||
// Resetting the 'forum' and 'prv' field when it isn't a forum
|
|
||||||
if ($contact_fields['contact-type'] != Contact::ACCOUNT_TYPE_COMMUNITY) {
|
if ($contact_fields['contact-type'] != Contact::ACCOUNT_TYPE_COMMUNITY) {
|
||||||
|
// Resetting the 'forum' and 'prv' field when it isn't a forum
|
||||||
$contact_fields['forum'] = false;
|
$contact_fields['forum'] = false;
|
||||||
$contact_fields['prv'] = false;
|
$contact_fields['prv'] = false;
|
||||||
|
} else {
|
||||||
|
// Otherwise set the corresponding forum type
|
||||||
|
$contact_fields['forum'] = !$manually_approve;
|
||||||
|
$contact_fields['prv'] = $manually_approve;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2850,19 +2850,41 @@ class DFRN
|
||||||
|
|
||||||
// The account type is new since 3.5.1
|
// The account type is new since 3.5.1
|
||||||
if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
|
if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
|
||||||
|
// Hint: We are using separate update calls for uid=0 and uid!=0 since a combined call is bad for the database performance
|
||||||
|
|
||||||
$accounttype = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:account_type/text()"));
|
$accounttype = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:account_type/text()"));
|
||||||
|
|
||||||
if ($accounttype != $importer["contact-type"]) {
|
if ($accounttype != $importer["contact-type"]) {
|
||||||
DBA::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
|
DBA::update('contact', ['contact-type' => $accounttype], ['id' => $importer['id']]);
|
||||||
|
|
||||||
|
// Updating the public contact as well
|
||||||
|
DBA::update('contact', ['contact-type' => $accounttype], ['uid' => 0, 'nurl' => $importer['nurl']]);
|
||||||
}
|
}
|
||||||
// A forum contact can either have set "forum" or "prv" - but not both
|
// A forum contact can either have set "forum" or "prv" - but not both
|
||||||
if (($accounttype == Contact::ACCOUNT_TYPE_COMMUNITY) && (($forum != $importer["forum"]) || ($forum == $importer["prv"]))) {
|
if ($accounttype == Contact::ACCOUNT_TYPE_COMMUNITY) {
|
||||||
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer["id"]];
|
// It's a forum, so either set the public or private forum flag
|
||||||
|
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer['id']];
|
||||||
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
|
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
|
||||||
|
|
||||||
|
// Updating the public contact as well
|
||||||
|
$condition = ['(`forum` != ? OR `prv` != ?) AND `uid` = 0 AND `nurl` = ?', $forum, !$forum, $importer['nurl']];
|
||||||
|
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
|
||||||
|
} else {
|
||||||
|
// It's not a forum, so remove the flags
|
||||||
|
$condition = ['(`forum` OR `prv`) AND `id` = ?', $importer['id']];
|
||||||
|
DBA::update('contact', ['forum' => false, 'prv' => false], $condition);
|
||||||
|
|
||||||
|
// Updating the public contact as well
|
||||||
|
$condition = ['(`forum` OR `prv`) AND `uid` = 0 AND `nurl` = ?', $importer['nurl']];
|
||||||
|
DBA::update('contact', ['forum' => false, 'prv' => false], $condition);
|
||||||
}
|
}
|
||||||
} elseif ($forum != $importer["forum"]) { // Deprecated since 3.5.1
|
} elseif ($forum != $importer["forum"]) { // Deprecated since 3.5.1
|
||||||
$condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
|
$condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
|
||||||
DBA::update('contact', ['forum' => $forum], $condition);
|
DBA::update('contact', ['forum' => $forum], $condition);
|
||||||
|
|
||||||
|
// Updating the public contact as well
|
||||||
|
$condition = ['`forum` != ? AND `uid` = 0 AND `nurl` = ?', $forum, $importer['nurl']];
|
||||||
|
DBA::update('contact', ['forum' => $forum], $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
|
@ -60,7 +61,12 @@ class OnePoll
|
||||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We currently don't do anything with AP here
|
// These three networks can be able to speak AP, so we are trying to fetch AP profile data here
|
||||||
|
if (in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::DFRN])) {
|
||||||
|
APContact::getByURL($contact['url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We currently don't do anything more with AP here
|
||||||
if ($contact['network'] === Protocol::ACTIVITYPUB) {
|
if ($contact['network'] === Protocol::ACTIVITYPUB) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue