Added field for "shared" inbox
This commit is contained in:
parent
18f3ff7b8e
commit
fe0c516c3f
2 changed files with 8 additions and 7 deletions
|
@ -537,7 +537,8 @@ return [
|
||||||
"success" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last successful delivery"],
|
"success" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last successful delivery"],
|
||||||
"failure" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last failed delivery"],
|
"failure" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last failed delivery"],
|
||||||
"previous" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Previous delivery date"],
|
"previous" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Previous delivery date"],
|
||||||
"archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the inbox archived?"]
|
"archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the inbox archived?"],
|
||||||
|
"shared" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is it a shared inbox?"]
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["url"]
|
"PRIMARY" => ["url"]
|
||||||
|
|
|
@ -123,14 +123,14 @@ class APContact extends BaseObject
|
||||||
$apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
|
$apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
|
||||||
$apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
|
$apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
|
||||||
$apcontact['inbox'] = JsonLD::fetchElement($compacted, 'ldp:inbox', '@id');
|
$apcontact['inbox'] = JsonLD::fetchElement($compacted, 'ldp:inbox', '@id');
|
||||||
self::unarchiveInbox($apcontact['inbox']);
|
self::unarchiveInbox($apcontact['inbox'], false);
|
||||||
|
|
||||||
$apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
|
$apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
|
||||||
|
|
||||||
$apcontact['sharedinbox'] = '';
|
$apcontact['sharedinbox'] = '';
|
||||||
if (!empty($compacted['as:endpoints'])) {
|
if (!empty($compacted['as:endpoints'])) {
|
||||||
$apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id');
|
$apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id');
|
||||||
self::unarchiveInbox($apcontact['sharedinbox']);
|
self::unarchiveInbox($apcontact['sharedinbox'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername');
|
$apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername');
|
||||||
|
@ -240,7 +240,7 @@ class APContact extends BaseObject
|
||||||
*
|
*
|
||||||
* @param string $url inbox url
|
* @param string $url inbox url
|
||||||
*/
|
*/
|
||||||
private static function unarchiveInbox($url)
|
private static function unarchiveInbox($url, $shared)
|
||||||
{
|
{
|
||||||
if (empty($url)) {
|
if (empty($url)) {
|
||||||
return;
|
return;
|
||||||
|
@ -248,12 +248,12 @@ class APContact extends BaseObject
|
||||||
|
|
||||||
$now = DateTimeFormat::utcNow();
|
$now = DateTimeFormat::utcNow();
|
||||||
|
|
||||||
|
$fields = ['archive' => false, 'success' => $now, 'shared' => $shared];
|
||||||
|
|
||||||
if (!DBA::exists('inbox-status', ['url' => $url])) {
|
if (!DBA::exists('inbox-status', ['url' => $url])) {
|
||||||
$fields = ['archive' => false, 'success' => $now,
|
$fields = array_merge($fields, ['url' => $url, 'created' => $now]);
|
||||||
'url' => $url, 'created' => $now];
|
|
||||||
DBA::insert('inbox-status', $fields);
|
DBA::insert('inbox-status', $fields);
|
||||||
} else {
|
} else {
|
||||||
$fields = ['archive' => false, 'success' => $now];
|
|
||||||
DBA::update('inbox-status', $fields, ['url' => $url]);
|
DBA::update('inbox-status', $fields, ['url' => $url]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue