Skip to content

Commit

Permalink
fix(entity): Migrate types to OCP\DB\Types
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 28, 2024
1 parent 2da43a0 commit d5fdbcd
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 114 deletions.
13 changes: 7 additions & 6 deletions lib/Model/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setRoomId(int $roomId)
Expand Down Expand Up @@ -54,12 +55,12 @@ class Attachment extends Entity {
protected $actorId;

public function __construct() {
$this->addType('roomId', 'int');
$this->addType('messageId', 'int');
$this->addType('messageTime', 'int');
$this->addType('objectType', 'string');
$this->addType('actorType', 'string');
$this->addType('actorId', 'string');
$this->addType('roomId', Types::BIGINT);
$this->addType('messageId', Types::BIGINT);
$this->addType('messageTime', Types::BIGINT);
$this->addType('objectType', Types::STRING);
$this->addType('actorType', Types::STRING);
$this->addType('actorId', Types::STRING);
}

/**
Expand Down
49 changes: 25 additions & 24 deletions lib/Model/Attendee.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setRoomId(int $roomId)
Expand Down Expand Up @@ -127,30 +128,30 @@ class Attendee extends Entity {
protected int $lastAttendeeActivity = 0;

public function __construct() {
$this->addType('roomId', 'int');
$this->addType('actorType', 'string');
$this->addType('actorId', 'string');
$this->addType('displayName', 'string');
$this->addType('pin', 'string');
$this->addType('participantType', 'int');
$this->addType('favorite', 'bool');
$this->addType('archived', 'bool');
$this->addType('notificationLevel', 'int');
$this->addType('notificationCalls', 'int');
$this->addType('lastJoinedCall', 'int');
$this->addType('lastReadMessage', 'int');
$this->addType('lastMentionMessage', 'int');
$this->addType('lastMentionDirect', 'int');
$this->addType('readPrivacy', 'int');
$this->addType('permissions', 'int');
$this->addType('accessToken', 'string');
$this->addType('remoteId', 'string');
$this->addType('invitedCloudId', 'string');
$this->addType('phoneNumber', 'string');
$this->addType('callId', 'string');
$this->addType('state', 'int');
$this->addType('unreadMessages', 'int');
$this->addType('lastAttendeeActivity', 'int');
$this->addType('roomId', Types::BIGINT);
$this->addType('actorType', Types::STRING);
$this->addType('actorId', Types::STRING);
$this->addType('displayName', Types::STRING);
$this->addType('pin', Types::STRING);
$this->addType('participantType', Types::SMALLINT);
$this->addType('favorite', Types::BOOLEAN);
$this->addType('archived', Types::BOOLEAN);
$this->addType('notificationLevel', Types::INTEGER);
$this->addType('notificationCalls', Types::INTEGER);
$this->addType('lastJoinedCall', Types::INTEGER);
$this->addType('lastReadMessage', Types::INTEGER);
$this->addType('lastMentionMessage', Types::INTEGER);
$this->addType('lastMentionDirect', Types::BIGINT);
$this->addType('readPrivacy', Types::SMALLINT);
$this->addType('permissions', Types::INTEGER);
$this->addType('accessToken', Types::STRING);
$this->addType('remoteId', Types::STRING);
$this->addType('invitedCloudId', Types::STRING);
$this->addType('phoneNumber', Types::STRING);
$this->addType('callId', Types::STRING);
$this->addType('state', Types::SMALLINT);
$this->addType('unreadMessages', Types::BIGINT);
$this->addType('lastAttendeeActivity', Types::BIGINT);
}

public function getDisplayName(): string {
Expand Down
21 changes: 11 additions & 10 deletions lib/Model/Ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use OCA\Talk\ResponseDefinitions;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @psalm-import-type TalkBan from ResponseDefinitions
Expand Down Expand Up @@ -49,16 +50,16 @@ class Ban extends Entity implements \JsonSerializable {
protected ?string $internalNote = null;

public function __construct() {
$this->addType('id', 'int');
$this->addType('moderatorActorType', 'string');
$this->addType('moderatorActorId', 'string');
$this->addType('moderatorDisplayname', 'string');
$this->addType('roomId', 'int');
$this->addType('bannedActorType', 'string');
$this->addType('bannedActorId', 'string');
$this->addType('bannedDisplayname', 'string');
$this->addType('bannedTime', 'datetime');
$this->addType('internalNote', 'string');
$this->addType('id', Types::BIGINT);
$this->addType('moderatorActorType', Types::STRING);
$this->addType('moderatorActorId', Types::STRING);
$this->addType('moderatorDisplayname', Types::STRING);
$this->addType('roomId', Types::BIGINT);
$this->addType('bannedActorType', Types::STRING);
$this->addType('bannedActorId', Types::STRING);
$this->addType('bannedDisplayname', Types::STRING);
$this->addType('bannedTime', Types::DATETIME);
$this->addType('internalNote', Types::TEXT);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions lib/Model/BotConversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setBotId(int $botId)
Expand All @@ -24,9 +25,9 @@ class BotConversation extends Entity implements \JsonSerializable {
protected int $state = Bot::STATE_DISABLED;

public function __construct() {
$this->addType('bot_id', 'int');
$this->addType('token', 'string');
$this->addType('state', 'int');
$this->addType('bot_id', Types::BIGINT);
$this->addType('token', Types::STRING);
$this->addType('state', Types::SMALLINT);
}

public function jsonSerialize(): array {
Expand Down
21 changes: 11 additions & 10 deletions lib/Model/BotServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use OCA\Talk\ResponseDefinitions;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setName(string $name)
Expand Down Expand Up @@ -48,16 +49,16 @@ class BotServer extends Entity implements \JsonSerializable {
protected int $features = Bot::FEATURE_NONE;

public function __construct() {
$this->addType('name', 'string');
$this->addType('url', 'string');
$this->addType('url_hash', 'string');
$this->addType('description', 'string');
$this->addType('secret', 'string');
$this->addType('error_count', 'int');
$this->addType('last_error_date', 'datetime');
$this->addType('last_error_message', 'string');
$this->addType('state', 'int');
$this->addType('features', 'int');
$this->addType('name', Types::STRING);
$this->addType('url', Types::STRING);
$this->addType('url_hash', Types::STRING);
$this->addType('description', Types::STRING);
$this->addType('secret', Types::STRING);
$this->addType('error_count', Types::BIGINT);
$this->addType('last_error_date', Types::DATETIME);
$this->addType('last_error_message', Types::STRING);
$this->addType('state', Types::SMALLINT);
$this->addType('features', Types::INTEGER);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions lib/Model/Consent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setToken(string $token)
Expand All @@ -27,10 +28,10 @@ class Consent extends Entity implements \JsonSerializable {
protected ?\DateTime $dateTime = null;

public function __construct() {
$this->addType('token', 'string');
$this->addType('actorType', 'string');
$this->addType('actorId', 'string');
$this->addType('dateTime', 'datetime');
$this->addType('token', Types::STRING);
$this->addType('actorType', Types::STRING);
$this->addType('actorId', Types::STRING);
$this->addType('dateTime', Types::DATETIME);
}

public function jsonSerialize(): array {
Expand Down
21 changes: 11 additions & 10 deletions lib/Model/Invitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setUserId(string $userId)
Expand Down Expand Up @@ -48,16 +49,16 @@ class Invitation extends Entity implements \JsonSerializable {
protected string $localCloudId = '';

public function __construct() {
$this->addType('userId', 'string');
$this->addType('state', 'int');
$this->addType('localRoomId', 'int');
$this->addType('accessToken', 'string');
$this->addType('remoteServerUrl', 'string');
$this->addType('remoteToken', 'string');
$this->addType('remoteAttendeeId', 'int');
$this->addType('inviterCloudId', 'string');
$this->addType('inviterDisplayName', 'string');
$this->addType('localCloudId', 'string');
$this->addType('userId', Types::STRING);
$this->addType('state', Types::SMALLINT);
$this->addType('localRoomId', Types::BIGINT);
$this->addType('accessToken', Types::STRING);
$this->addType('remoteServerUrl', Types::STRING);
$this->addType('remoteToken', Types::STRING);
$this->addType('remoteAttendeeId', Types::BIGINT);
$this->addType('inviterCloudId', Types::STRING);
$this->addType('inviterDisplayName', Types::STRING);
$this->addType('localCloudId', Types::STRING);
}

/**
Expand Down
23 changes: 12 additions & 11 deletions lib/Model/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OCA\Talk\ResponseDefinitions;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @psalm-method int<1, max> getId()
Expand Down Expand Up @@ -70,17 +71,17 @@ class Poll extends Entity {
protected int $maxVotes = self::MAX_VOTES_UNLIMITED;

public function __construct() {
$this->addType('roomId', 'int');
$this->addType('question', 'string');
$this->addType('options', 'string');
$this->addType('votes', 'string');
$this->addType('numVoters', 'int');
$this->addType('actorType', 'string');
$this->addType('actorId', 'string');
$this->addType('displayName', 'string');
$this->addType('status', 'int');
$this->addType('resultMode', 'int');
$this->addType('maxVotes', 'int');
$this->addType('roomId', Types::BIGINT);
$this->addType('question', Types::TEXT);
$this->addType('options', Types::TEXT);
$this->addType('votes', Types::TEXT);
$this->addType('numVoters', Types::BIGINT);
$this->addType('actorType', Types::STRING);
$this->addType('actorId', Types::STRING);
$this->addType('displayName', Types::STRING);
$this->addType('status', Types::SMALLINT);
$this->addType('resultMode', Types::SMALLINT);
$this->addType('maxVotes', Types::INTEGER);
}

/**
Expand Down
29 changes: 15 additions & 14 deletions lib/Model/ProxyCacheMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OCA\Talk\ResponseDefinitions;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setLocalToken(string $localToken)
Expand Down Expand Up @@ -66,20 +67,20 @@ class ProxyCacheMessage extends Entity implements \JsonSerializable {
protected ?string $metaData = null;

public function __construct() {
$this->addType('localToken', 'string');
$this->addType('remoteServerUrl', 'string');
$this->addType('remoteToken', 'string');
$this->addType('remoteMessageId', 'int');
$this->addType('actorType', 'string');
$this->addType('actorId', 'string');
$this->addType('actorDisplayName', 'string');
$this->addType('messageType', 'string');
$this->addType('systemMessage', 'string');
$this->addType('expirationDatetime', 'datetime');
$this->addType('message', 'string');
$this->addType('messageParameters', 'string');
$this->addType('creationDatetime', 'datetime');
$this->addType('metaData', 'string');
$this->addType('localToken', Types::STRING);
$this->addType('remoteServerUrl', Types::STRING);
$this->addType('remoteToken', Types::STRING);
$this->addType('remoteMessageId', Types::BIGINT);
$this->addType('actorType', Types::STRING);
$this->addType('actorId', Types::STRING);
$this->addType('actorDisplayName', Types::STRING);
$this->addType('messageType', Types::STRING);
$this->addType('systemMessage', Types::STRING);
$this->addType('expirationDatetime', Types::DATETIME);
$this->addType('message', Types::TEXT);
$this->addType('messageParameters', Types::TEXT);
$this->addType('creationDatetime', Types::DATETIME);
$this->addType('metaData', Types::TEXT);
}

public function getParsedMessageParameters(): array {
Expand Down
9 changes: 5 additions & 4 deletions lib/Model/Reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use OCA\Talk\ResponseDefinitions;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setUserId(string $userId)
Expand All @@ -30,10 +31,10 @@ class Reminder extends Entity implements \JsonSerializable {
protected ?\DateTime $dateTime = null;

public function __construct() {
$this->addType('userId', 'string');
$this->addType('token', 'string');
$this->addType('messageId', 'int');
$this->addType('dateTime', 'datetime');
$this->addType('userId', Types::STRING);
$this->addType('token', Types::STRING);
$this->addType('messageId', Types::BIGINT);
$this->addType('dateTime', Types::DATETIME);
}

/**
Expand Down
15 changes: 8 additions & 7 deletions lib/Model/RetryNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setRemoteServer(string $remoteServer)
Expand Down Expand Up @@ -38,12 +39,12 @@ class RetryNotification extends Entity {
protected string $notification = '';

public function __construct() {
$this->addType('remoteServer', 'string');
$this->addType('numAttempts', 'int');
$this->addType('nextRetry', 'datetime');
$this->addType('notificationType', 'string');
$this->addType('resourceType', 'string');
$this->addType('providerId', 'string');
$this->addType('notification', 'string');
$this->addType('remoteServer', Types::STRING);
$this->addType('numAttempts', Types::INTEGER);
$this->addType('nextRetry', Types::DATETIME);
$this->addType('notificationType', Types::STRING);
$this->addType('resourceType', Types::STRING);
$this->addType('providerId', Types::STRING);
$this->addType('notification', Types::TEXT);
}
}
11 changes: 6 additions & 5 deletions lib/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* A session is the "I'm online in this conversation" state of Talk, you get one
Expand Down Expand Up @@ -49,11 +50,11 @@ class Session extends Entity {
protected $state;

public function __construct() {
$this->addType('attendeeId', 'int');
$this->addType('sessionId', 'string');
$this->addType('inCall', 'int');
$this->addType('lastPing', 'int');
$this->addType('state', 'int');
$this->addType('attendeeId', Types::BIGINT);
$this->addType('sessionId', Types::STRING);
$this->addType('inCall', Types::INTEGER);
$this->addType('lastPing', Types::INTEGER);
$this->addType('state', Types::SMALLINT);
}

/**
Expand Down
Loading

0 comments on commit d5fdbcd

Please sign in to comment.