Skip to content

Commit

Permalink
Rename Threepids => ThreePID
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 19, 2023
1 parent 37a8fcd commit b6280bb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion application/src/Controller/BackOfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Entity\Password;
use App\Entity\RoomMember;
use App\Entity\Room;
use App\Entity\Threepids;
use App\Entity\ThreePID;
use App\Entity\Tokens;
use App\Entity\User;
use App\Traits\GeneralTrait;
Expand Down
20 changes: 10 additions & 10 deletions application/src/Controller/SynapseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use App\Entity\User;
use App\Entity\Threepids;
use App\Entity\ThreePID;
use App\Entity\RoomMember;
use App\Entity\Room;
use App\Entity\Tokens;
Expand Down Expand Up @@ -72,8 +72,8 @@ public function registerUser(string $serverID, string $userID, Request $request)
}

// Finally return user info.
$threepids = $this->getDoctrine()->getRepository(Threepids::class)
->getUserThreepids($serverID, $user->getId());
$threepids = $this->getDoctrine()->getRepository(ThreePID::class)
->getUserThreePIDs($serverID, $user->getId());
$externalids = $this->getDoctrine()->getRepository(ExternalId::class)
->getUserExternalIds($serverID, $user->getId());

Expand Down Expand Up @@ -137,7 +137,7 @@ private function upsertUser(string $serverID, string $userID, Request $request,
{
$payload = json_decode($request->getContent());
$entityManager = $this->getDoctrine()->getManager();
$hasThreepids = false;
$hasThreePIDs = false;
$hasExternalIds = false;

$user->setServerid($serverID);
Expand All @@ -149,24 +149,24 @@ private function upsertUser(string $serverID, string $userID, Request $request,
// Process threepids.
if (!empty($payload->threepids)){
foreach ($payload->threepids as $pid) {
$threepid = $entityManager->getRepository(Threepids::class)
$threepid = $entityManager->getRepository(ThreePID::class)
->findOneBy(['serverid' => $serverID, 'userid' => $user->getId(), 'medium' => $pid->medium]);
if (!$threepid) {
// New user, or existing user without any associated Threepids.
$threepid = new Threepids();
// New user, or existing user without any associated ThreePID.
$threepid = new ThreePID();
$threepid->setMedium($pid->medium);
$threepid->setAddress($pid->address);
$threepid->setServerid($serverID);

$user->addThreepid($threepid);
$user->addThreePID($threepid);
$threepid->setUserid($user);
} else {
// Updating existing.
$threepid->setAddress($pid->address);
}
$entityManager->persist($threepid);
}
$hasThreepids = true;
$hasThreePIDs = true;
}

// Process access tokens.
Expand Down Expand Up @@ -225,7 +225,7 @@ private function upsertUser(string $serverID, string $userID, Request $request,
'erased' => false
];

if ($hasThreepids) {
if ($hasThreePIDs) {
$payload->threepids['validated_at'] = time();
$payload->threepids['added_at'] = time();
$responseObj->threepids = [$payload->threepids];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace App\Entity;

use App\Repository\ThreepidsRepository;
use App\Repository\ThreePIDRepository;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass=ThreepidsRepository::class)
* @ORM\Entity(repositoryClass=ThreePIDRepository::class)
*/
class Threepids
class ThreePID
{
/**
* @ORM\Id
Expand Down
10 changes: 5 additions & 5 deletions application/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class User
private $displayname;

/**
* @ORM\OneToMany(targetEntity=Threepids::class, mappedBy="userid", cascade={"persist", "remove"})
* @ORM\OneToMany(targetEntity=ThreePID::class, mappedBy="userid", cascade={"persist", "remove"})
*/
private $threepids;

Expand Down Expand Up @@ -128,14 +128,14 @@ public function setDisplayname(string $displayname): self
}

/**
* @return Collection<int, Threepids>
* @return Collection<int, ThreePID>
*/
public function getThreepids(): Collection
public function getThreePIDs(): Collection
{
return $this->threepids;
}

public function addThreepid(Threepids $threepid): self
public function addThreePID(ThreePID $threepid): self
{
if (!$this->threepids->contains($threepid)) {
$this->threepids[] = $threepid;
Expand All @@ -145,7 +145,7 @@ public function addThreepid(Threepids $threepid): self
return $this;
}

public function removeThreepid(Threepids $threepid): self
public function removeThreepid(ThreePID $threepid): self
{
if ($this->threepids->removeElement($threepid)) {
// set the owning side to null (unless already changed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

namespace App\Repository;

use App\Entity\Threepids;
use App\Entity\ThreePID;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends ServiceEntityRepository<Threepids>
* @extends ServiceEntityRepository<ThreePID>
*
* @method Threepids|null find($id, $lockMode = null, $lockVersion = null)
* @method Threepids|null findOneBy(array $criteria, array $orderBy = null)
* @method Threepids[] findAll()
* @method Threepids[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method ThreePID|null find($id, $lockMode = null, $lockVersion = null)
* @method ThreePID|null findOneBy(array $criteria, array $orderBy = null)
* @method ThreePID[] findAll()
* @method ThreePID[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ThreepidsRepository extends ServiceEntityRepository
class ThreePIDRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Threepids::class);
parent::__construct($registry, ThreePID::class);
}

/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function add(Threepids $entity, bool $flush = true): void
public function add(ThreePID $entity, bool $flush = true): void
{
$this->_em->persist($entity);
if ($flush) {
Expand All @@ -39,7 +39,7 @@ public function add(Threepids $entity, bool $flush = true): void
* @throws ORMException
* @throws OptimisticLockException
*/
public function remove(Threepids $entity, bool $flush = true): void
public function remove(ThreePID $entity, bool $flush = true): void
{
$this->_em->remove($entity);
if ($flush) {
Expand All @@ -54,7 +54,7 @@ public function remove(Threepids $entity, bool $flush = true): void
* @param string $serverID
* @return float|int|mixed|string
*/
public function getUserThreepids(string $serverID, string $userID)
public function getUserThreePIDs(string $serverID, string $userID)
{
return $this->createQueryBuilder('t')
->andWhere('t.userid = :userid')
Expand Down

0 comments on commit b6280bb

Please sign in to comment.