Merge pull request #9118 from annando/manually-aprove
New field "manually-approve" for contact table
This commit is contained in:
commit
9870ab8446
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2020.09-dev (Red Hot Poker)
|
-- Friendica 2020.09-dev (Red Hot Poker)
|
||||||
-- DB_UPDATE_VERSION 1365
|
-- DB_UPDATE_VERSION 1366
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +98,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
||||||
`forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
|
`forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
|
||||||
`prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
|
`prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
|
||||||
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
|
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
|
||||||
|
`manually-approve` boolean COMMENT '',
|
||||||
`hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
|
`hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||||
`archive` boolean NOT NULL DEFAULT '0' COMMENT '',
|
`archive` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||||
`pending` boolean NOT NULL DEFAULT '1' COMMENT '',
|
`pending` boolean NOT NULL DEFAULT '1' COMMENT '',
|
||||||
|
@ -1540,6 +1541,7 @@ CREATE VIEW `owner-view` AS SELECT
|
||||||
`contact`.`forum` AS `forum`,
|
`contact`.`forum` AS `forum`,
|
||||||
`contact`.`prv` AS `prv`,
|
`contact`.`prv` AS `prv`,
|
||||||
`contact`.`contact-type` AS `contact-type`,
|
`contact`.`contact-type` AS `contact-type`,
|
||||||
|
`contact`.`manually-approve` AS `manually-approve`,
|
||||||
`contact`.`hidden` AS `hidden`,
|
`contact`.`hidden` AS `hidden`,
|
||||||
`contact`.`archive` AS `archive`,
|
`contact`.`archive` AS `archive`,
|
||||||
`contact`.`pending` AS `pending`,
|
`contact`.`pending` AS `pending`,
|
||||||
|
|
|
@ -1802,7 +1802,7 @@ 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',
|
$fields = ['uid', 'avatar', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe', 'manually-approve',
|
||||||
'unsearchable', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
|
'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]);
|
||||||
|
@ -1850,12 +1850,9 @@ class Contact
|
||||||
$ret['forum'] = false;
|
$ret['forum'] = false;
|
||||||
$ret['prv'] = false;
|
$ret['prv'] = false;
|
||||||
$ret['contact-type'] = $ret['account-type'];
|
$ret['contact-type'] = $ret['account-type'];
|
||||||
if ($ret['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
|
if (($ret['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY) && isset($ret['manually-approve'])) {
|
||||||
$apcontact = APContact::getByURL($ret['url'], false);
|
$ret['forum'] = (bool)!$ret['manually-approve'];
|
||||||
if (isset($apcontact['manually-approve'])) {
|
$ret['prv'] = (bool)!$ret['forum'];
|
||||||
$ret['forum'] = (bool)!$apcontact['manually-approve'];
|
|
||||||
$ret['prv'] = (bool)!$ret['forum'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2122,11 +2119,8 @@ class Contact
|
||||||
$hidden = (($protocol === Protocol::MAIL) ? 1 : 0);
|
$hidden = (($protocol === Protocol::MAIL) ? 1 : 0);
|
||||||
|
|
||||||
$pending = false;
|
$pending = false;
|
||||||
if ($protocol == Protocol::ACTIVITYPUB) {
|
if (($protocol == Protocol::ACTIVITYPUB) && isset($ret['manually-approve'])) {
|
||||||
$apcontact = APContact::getByURL($ret['url'], false);
|
$pending = (bool)$ret['manually-approve'];
|
||||||
if (isset($apcontact['manually-approve'])) {
|
|
||||||
$pending = (bool)$apcontact['manually-approve'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($protocol, [Protocol::MAIL, Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
|
if (in_array($protocol, [Protocol::MAIL, Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
|
||||||
|
|
|
@ -91,12 +91,12 @@ class Probe
|
||||||
"community", "keywords", "location", "about", "hide",
|
"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", "baseurl", "gsid"];
|
"priority", "network", "pubkey", "manually-approve", "baseurl", "gsid"];
|
||||||
|
|
||||||
$newdata = [];
|
$newdata = [];
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if (isset($data[$field])) {
|
if (isset($data[$field])) {
|
||||||
if (in_array($field, ["gsid", "hide", "account-type"])) {
|
if (in_array($field, ["gsid", "hide", "account-type", "manually-approve"])) {
|
||||||
$newdata[$field] = (int)$data[$field];
|
$newdata[$field] = (int)$data[$field];
|
||||||
} else {
|
} else {
|
||||||
$newdata[$field] = $data[$field];
|
$newdata[$field] = $data[$field];
|
||||||
|
@ -1454,6 +1454,7 @@ class Probe
|
||||||
&& !empty($hcard_url)
|
&& !empty($hcard_url)
|
||||||
) {
|
) {
|
||||||
$data["network"] = Protocol::DIASPORA;
|
$data["network"] = Protocol::DIASPORA;
|
||||||
|
$data["manually-approve"] = false;
|
||||||
|
|
||||||
// The Diaspora handle must always be lowercase
|
// The Diaspora handle must always be lowercase
|
||||||
if (!empty($data["addr"])) {
|
if (!empty($data["addr"])) {
|
||||||
|
@ -1544,6 +1545,7 @@ class Probe
|
||||||
&& isset($data["url"])
|
&& isset($data["url"])
|
||||||
) {
|
) {
|
||||||
$data["network"] = Protocol::OSTATUS;
|
$data["network"] = Protocol::OSTATUS;
|
||||||
|
$data["manually-approve"] = false;
|
||||||
} else {
|
} else {
|
||||||
return $short ? false : [];
|
return $short ? false : [];
|
||||||
}
|
}
|
||||||
|
@ -2218,7 +2220,8 @@ class Probe
|
||||||
'following' => $approfile['following'], 'followers' => $approfile['followers'],
|
'following' => $approfile['following'], 'followers' => $approfile['followers'],
|
||||||
'inbox' => $approfile['inbox'], 'outbox' => $approfile['outbox'],
|
'inbox' => $approfile['inbox'], 'outbox' => $approfile['outbox'],
|
||||||
'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN,
|
'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN,
|
||||||
'pubkey' => $profile['upubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $profile['gsid']];
|
'pubkey' => $profile['upubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $profile['gsid'],
|
||||||
|
'manually-approve' => in_array($profile['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP])];
|
||||||
return self::rearrangeData($data);
|
return self::rearrangeData($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,17 @@ class Account extends BaseEntity
|
||||||
$publicContact['nick'] :
|
$publicContact['nick'] :
|
||||||
$publicContact['addr'];
|
$publicContact['addr'];
|
||||||
$this->display_name = $publicContact['name'];
|
$this->display_name = $publicContact['name'];
|
||||||
$this->locked = !empty($apcontact['manually-approve']);
|
$this->locked = $publicContact['manually-approve'] ?? !empty($apcontact['manually-approve']);
|
||||||
$this->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
|
$this->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
|
||||||
$this->discoverable = !$publicContact['unsearchable'];
|
$this->discoverable = !$publicContact['unsearchable'];
|
||||||
$this->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
|
$this->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
|
||||||
$this->created_at = DateTimeFormat::utc($publicContact['created'], DateTimeFormat::ATOM);
|
|
||||||
|
$publicContactCreated = $publicContact['created'] ?: DBA::NULL_DATETIME;
|
||||||
|
$userContactCreated = $userContact['created'] ?? DBA::NULL_DATETIME;
|
||||||
|
|
||||||
|
$created = $userContactCreated < $publicContactCreated && ($userContactCreated != DBA::NULL_DATETIME) ? $userContactCreated : $publicContactCreated;
|
||||||
|
$this->created_at = DateTimeFormat::utc($created, DateTimeFormat::ATOM);
|
||||||
|
|
||||||
$this->note = BBCode::convert($publicContact['about'], false);
|
$this->note = BBCode::convert($publicContact['about'], false);
|
||||||
$this->url = $publicContact['url'];
|
$this->url = $publicContact['url'];
|
||||||
$this->avatar = $userContact['avatar'] ?? $publicContact['avatar'];
|
$this->avatar = $userContact['avatar'] ?? $publicContact['avatar'];
|
||||||
|
|
|
@ -157,6 +157,7 @@ class ActivityPub
|
||||||
$profile['poll'] = $apcontact['outbox'];
|
$profile['poll'] = $apcontact['outbox'];
|
||||||
$profile['pubkey'] = $apcontact['pubkey'];
|
$profile['pubkey'] = $apcontact['pubkey'];
|
||||||
$profile['subscribe'] = $apcontact['subscribe'];
|
$profile['subscribe'] = $apcontact['subscribe'];
|
||||||
|
$profile['manually-approve'] = $apcontact['manually-approve'];
|
||||||
$profile['baseurl'] = $apcontact['baseurl'];
|
$profile['baseurl'] = $apcontact['baseurl'];
|
||||||
$profile['gsid'] = $apcontact['gsid'];
|
$profile['gsid'] = $apcontact['gsid'];
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1365);
|
define('DB_UPDATE_VERSION', 1366);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -153,6 +153,7 @@ return [
|
||||||
"forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"],
|
"forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"],
|
||||||
"prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"],
|
"prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"],
|
||||||
"contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
|
"contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
|
"manually-approve" => ["type" => "boolean", "comment" => ""],
|
||||||
"hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
"hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
"archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
"archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
"pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
|
"pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
|
||||||
|
|
|
@ -184,6 +184,7 @@ return [
|
||||||
"forum" => ["contact", "forum"],
|
"forum" => ["contact", "forum"],
|
||||||
"prv" => ["contact", "prv"],
|
"prv" => ["contact", "prv"],
|
||||||
"contact-type" => ["contact", "contact-type"],
|
"contact-type" => ["contact", "contact-type"],
|
||||||
|
"manually-approve" => ["contact", "manually-approve"],
|
||||||
"hidden" => ["contact", "hidden"],
|
"hidden" => ["contact", "hidden"],
|
||||||
"archive" => ["contact", "archive"],
|
"archive" => ["contact", "archive"],
|
||||||
"pending" => ["contact", "pending"],
|
"pending" => ["contact", "pending"],
|
||||||
|
|
Loading…
Reference in a new issue