Skip to content

Commit 32cea43

Browse files
committed
Added the field is_forum to the class Chat.
1 parent aca559b commit 32cea43

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/DB.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,16 @@ public static function insertChat(Chat $chat, ?string $date = null, ?int $migrat
493493
try {
494494
$sth = self::$pdo->prepare('
495495
INSERT IGNORE INTO `' . TB_CHAT . '`
496-
(`id`, `type`, `title`, `username`, `first_name`, `last_name`, `created_at` ,`updated_at`, `old_id`)
496+
(`id`, `type`, `title`, `username`, `first_name`, `last_name`, `is_forum`, `created_at` ,`updated_at`, `old_id`)
497497
VALUES
498-
(:id, :type, :title, :username, :first_name, :last_name, :created_at, :updated_at, :old_id)
498+
(:id, :type, :title, :username, :first_name, :last_name, :is_forum, :created_at, :updated_at, :old_id)
499499
ON DUPLICATE KEY UPDATE
500500
`type` = VALUES(`type`),
501501
`title` = VALUES(`title`),
502502
`username` = VALUES(`username`),
503503
`first_name` = VALUES(`first_name`),
504504
`last_name` = VALUES(`last_name`),
505+
`is_forum` = VALUES(`is_forum`),
505506
`updated_at` = VALUES(`updated_at`)
506507
');
507508

@@ -523,6 +524,7 @@ public static function insertChat(Chat $chat, ?string $date = null, ?int $migrat
523524
$sth->bindValue(':username', $chat->getUsername());
524525
$sth->bindValue(':first_name', $chat->getFirstName());
525526
$sth->bindValue(':last_name', $chat->getLastName());
527+
$sth->bindValue(':is_forum', $chat->getIsForum());
526528
$date = $date ?: self::getTimestamp();
527529
$sth->bindValue(':created_at', $date);
528530
$sth->bindValue(':updated_at', $date);

structure.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CREATE TABLE IF NOT EXISTS `chat` (
2121
`username` CHAR(255) DEFAULT NULL COMMENT 'Username, for private chats, supergroups and channels if available',
2222
`first_name` CHAR(255) DEFAULT NULL COMMENT 'First name of the other party in a private chat',
2323
`last_name` CHAR(255) DEFAULT NULL COMMENT 'Last name of the other party in a private chat',
24+
`is_forum` TINYINT(1) DEFAULT 0 COMMENT 'True, if the supergroup chat is a forum (has topics enabled)',
2425
`all_members_are_administrators` tinyint(1) DEFAULT 0 COMMENT 'True if a all members of this group are admins',
2526
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
2627
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update',

utils/db-schema-update/new-release.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ ALTER TABLE `message`
44
ADD COLUMN `forum_topic_created` TEXT NULL DEFAULT NULL COMMENT 'Service message: forum topic created' AFTER `proximity_alert_triggered`,
55
ADD COLUMN `forum_topic_closed` TEXT NULL DEFAULT NULL COMMENT 'Service message: forum topic closed' AFTER `forum_topic_created`,
66
ADD COLUMN `forum_topic_reopened` TEXT NULL DEFAULT NULL COMMENT 'Service message: forum topic reopened' AFTER `forum_topic_closed`;
7+
8+
ALTER TABLE `chat`
9+
ADD COLUMN `is_forum` TINYINT(1) DEFAULT 0 COMMENT 'True, if the supergroup chat is a forum (has topics enabled)' AFTER `last_name`;

0 commit comments

Comments
 (0)