Add all_members_are_administrators field to Chat entity.

parent e6a7bcc7
......@@ -406,20 +406,22 @@ class DB
return false;
}
$chat_id = $chat->getId();
$chat_title = $chat->getTitle();
$chat_type = $chat->getType();
$chat_id = $chat->getId();
$chat_title = $chat->getTitle();
$chat_type = $chat->getType();
$chat_all_members_are_administrators = $chat->getAllMembersAreAdministrators();
try {
$sth = self::$pdo->prepare('
INSERT INTO `' . TB_CHAT . '`
(`id`, `type`, `title`, `created_at` ,`updated_at`, `old_id`)
INSERT IGNORE INTO `' . TB_CHAT . '`
(`id`, `type`, `title`, `all_members_are_administrators`, `created_at` ,`updated_at`, `old_id`)
VALUES
(:id, :type, :title, :date, :date, :oldid)
(:id, :type, :title, :all_members_are_administrators, :date, :date, :oldid)
ON DUPLICATE KEY UPDATE
`type` = :type,
`title` = :title,
`updated_at` = :date
`type` = :type,
`title` = :title,
`all_members_are_administrators` = :all_members_are_administrators,
`updated_at` = :date
');
if ($migrate_to_chat_id) {
......@@ -434,6 +436,7 @@ class DB
$sth->bindParam(':type', $chat_type, PDO::PARAM_INT);
$sth->bindParam(':title', $chat_title, PDO::PARAM_STR, 255);
$sth->bindParam(':all_members_are_administrators', $chat_all_members_are_administrators, PDO::PARAM_INT);
$sth->bindParam(':date', $date, PDO::PARAM_STR);
return $sth->execute();
......
......@@ -15,18 +15,20 @@ namespace Longman\TelegramBot\Entities;
*
* @link https://core.telegram.org/bots/api#chat
*
* @property int $id Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @property string $type Type of chat, can be either "private", "group", "supergroup" or "channel"
* @property string $title Optional. Title, for channels and group chats
* @property string $username Optional. Username, for private chats, supergroups and channels if available
* @property string $first_name Optional. First name of the other party in a private chat
* @property string $last_name Optional. Last name of the other party in a private chat
* @method int getId() Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @method string getType() Type of chat, can be either "private ", "group", "supergroup" or "channel"
* @method string getTitle() Optional. Title, for channels and group chats
* @method string getUsername() Optional. Username, for private chats, supergroups and channels if available
* @method string getFirstName() Optional. First name of the other party in a private chat
* @method string getLastName() Optional. Last name of the other party in a private chat
* @property int $id Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @property string $type Type of chat, can be either "private", "group", "supergroup" or "channel"
* @property string $title Optional. Title, for channels and group chats
* @property string $username Optional. Username, for private chats, supergroups and channels if available
* @property string $first_name Optional. First name of the other party in a private chat
* @property string $last_name Optional. Last name of the other party in a private chat
* @property bool $all_members_are_administrators Optional. True if a group has ‘All Members Are Admins’ enabled.
* @method int getId() Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @method string getType() Type of chat, can be either "private ", "group", "supergroup" or "channel"
* @method string getTitle() Optional. Title, for channels and group chats
* @method string getUsername() Optional. Username, for private chats, supergroups and channels if available
* @method string getFirstName() Optional. First name of the other party in a private chat
* @method string getLastName() Optional. Last name of the other party in a private chat
* @method bool getAllMembersAreAdministrators() Optional. True if a group has ‘All Members Are Admins’ enabled.
*/
class Chat extends Entity
{
......
......@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `chat` (
`id` bigint COMMENT 'Unique user or chat identifier',
`type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'Chat type, either private, group, supergroup or channel',
`title` CHAR(255) DEFAULT '' COMMENT 'Chat (group) title, is null if chat type is private',
`all_members_are_administrators` tinyint(1) DEFAULT 0 COMMENT 'True if a all members of this group are admins',
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update',
`old_id` bigint DEFAULT NULL COMMENT 'Unique chat identifier, this is filled when a group is converted to a supergroup',
......
......@@ -48,6 +48,7 @@ class TestHelpers
'last_name' => 'last',
'username' => 'name',
'type' => 'private',
'all_members_are_administrators' => false,
];
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment