Compare commits

..

No commits in common. "b6aa591f8c949d7dba91f7bf7f71efdb082b845b" and "f36a7f8563c2c27cd9b4398ce63ededf2b32d322" have entirely different histories.

5 changed files with 12 additions and 12 deletions

View file

@ -47,7 +47,7 @@
*/ */
public function getDomain(): ?string public function getDomain(): ?string
{ {
return strtolower($this->domain); return $this->domain;
} }
/** /**

View file

@ -34,18 +34,13 @@
// Check if host is making the request & the identifier is not empty // Check if host is making the request & the identifier is not empty
try try
{ {
$identifyAs = null;
if ($request->getPeer()->getUsername() === ReservedUsernames::HOST->value && $request->getIdentifyAs() !== null) if ($request->getPeer()->getUsername() === ReservedUsernames::HOST->value && $request->getIdentifyAs() !== null)
{ {
$identifyAs = $request->getIdentifyAs(); $identifyAs = $request->getIdentifyAs();
} }
else else
{ {
$requestingPeer = $request->getPeer(); $identifyAs = $request->getPeer()->getAddress();
if($requestingPeer->getUsername() !== ReservedUsernames::HOST->value)
{
$identifyAs = $requestingPeer->getAddress();
}
} }
} }
catch (DatabaseOperationException $e) catch (DatabaseOperationException $e)

View file

@ -20,8 +20,8 @@
*/ */
public function __construct(string $username, string $domain) public function __construct(string $username, string $domain)
{ {
$this->username = strtolower($username); $this->username = $username;
$this->domain = strtolower($domain); $this->domain = $domain;
} }
/** /**
@ -78,6 +78,11 @@
*/ */
public function isExternal(): bool public function isExternal(): bool
{ {
if($this->isHost())
{
return false;
}
return $this->domain !== Configuration::getInstanceConfiguration()->getDomain(); return $this->domain !== Configuration::getInstanceConfiguration()->getDomain();
} }

View file

@ -978,12 +978,12 @@
*/ */
public static function resolvePeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer public static function resolvePeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer
{ {
if(strtolower($peerAddress->getDomain()) !== strtolower(Configuration::getInstanceConfiguration()->getDomain())) if($peerAddress->getDomain() !== Configuration::getInstanceConfiguration()->getDomain())
{ {
return self::resolveExternalPeer($peerAddress, $identifiedAs); return self::resolveExternalPeer($peerAddress, $identifiedAs);
} }
if(strtolower($peerAddress->getUsername()) === strtolower(ReservedUsernames::HOST->value)) if($peerAddress->getUsername() === ReservedUsernames::HOST->value)
{ {
return new Peer([ return new Peer([
'address' => sprintf('%s@%s', ReservedUsernames::HOST->value, Configuration::getInstanceConfiguration()->getDomain()), 'address' => sprintf('%s@%s', ReservedUsernames::HOST->value, Configuration::getInstanceConfiguration()->getDomain()),

View file

@ -767,7 +767,7 @@
$contact = $johnClient->addressBookGetContact($aliceClient->getIdentifiedAs()); $contact = $johnClient->addressBookGetContact($aliceClient->getIdentifiedAs());
$this->assertInstanceOf(Contact::class, $contact); $this->assertInstanceOf(Contact::class, $contact);
$this->assertEquals($aliceClient->getIdentifiedAs()->getAddress(), $contact->getAddress()->getAddress()); $this->assertEquals($aliceClient->getIdentifiedAs(), $contact->getAddress()->getAddress());
$this->expectException(RpcException::class); $this->expectException(RpcException::class);
$johnClient->addressBookGetContact('non-existent@coffee.com'); $johnClient->addressBookGetContact('non-existent@coffee.com');