[ActivityPub][Explorer] Store remote's url properly

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-02 03:33:40 +00:00
parent 30f3e2c462
commit 53c46127c1
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 24 additions and 13 deletions

View File

@ -58,6 +58,7 @@ class ActivitypubActor extends Entity
private int $actor_id; private int $actor_id;
private string $inbox_uri; private string $inbox_uri;
private ?string $inbox_shared_uri = null; private ?string $inbox_shared_uri = null;
private string $url;
private DateTimeInterface $created; private DateTimeInterface $created;
private DateTimeInterface $modified; private DateTimeInterface $modified;
@ -72,6 +73,17 @@ class ActivitypubActor extends Entity
return $this; return $this;
} }
public function getUrl(): string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
public function getActorId(): int public function getActorId(): int
{ {
return $this->actor_id; return $this->actor_id;
@ -229,6 +241,7 @@ class ActivitypubActor extends Entity
'actor_id' => ['type' => 'int', 'not null' => true], 'actor_id' => ['type' => 'int', 'not null' => true],
'inbox_uri' => ['type' => 'text', 'not null' => true], 'inbox_uri' => ['type' => 'text', 'not null' => true],
'inbox_shared_uri' => ['type' => 'text'], 'inbox_shared_uri' => ['type' => 'text'],
'url' => ['type' => 'text'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],

View File

@ -238,7 +238,6 @@ class Explorer
'fullname' => $res['name'] ?? null, 'fullname' => $res['name'] ?? null,
'created' => new DateTime($res['published'] ?? 'now'), 'created' => new DateTime($res['published'] ?? 'now'),
'bio' => isset($res['summary']) ? mb_substr(Security::sanitize($res['summary']), 0, 1000) : null, 'bio' => isset($res['summary']) ? mb_substr(Security::sanitize($res['summary']), 0, 1000) : null,
'homepage' => $res['url'],
'is_local' => false, 'is_local' => false,
'modified' => new DateTime(), 'modified' => new DateTime(),
]; ];
@ -252,22 +251,21 @@ class Explorer
DB::persist($actor); DB::persist($actor);
// ActivityPub Actor // ActivityPub Actor
$aprofile = new ActivitypubActor(); $aprofile = ActivitypubActor::create([
$aprofile->setInboxUri($res['inbox']); 'inbox_uri' => $res['inbox'],
$aprofile->setInboxSharedUri($res['endpoints']['sharedInbox'] ?? $res['inbox']); 'inbox_shared_uri' => $res['endpoints']['sharedInbox'],
$aprofile->setUri($res['id']); 'uri' => $res['id'],
$aprofile->setActorId($actor->getId()); 'actor_id' => $actor->getId(),
$aprofile->setCreated(new DateTime()); 'url' => $res['url'] ?? null,
$aprofile->setModified(new DateTime()); ]);
DB::persist($aprofile); DB::persist($aprofile);
// Public Key // Public Key
$apRSA = new ActivitypubRsa(); $apRSA = ActivitypubRsa::create([
$apRSA->setActorId($actor->getID()); 'actor_id' => $actor->getID(),
$apRSA->setPublicKey($res['publicKey']['publicKeyPem']); 'public_key' => $res['publicKey']['publicKeyPem'],
$apRSA->setCreated(new DateTime()); ]);
$apRSA->setModified(new DateTime());
DB::persist($apRSA); DB::persist($apRSA);