Skip to content

Commit 7444c44

Browse files
committed
Added getForwardSenderName() method to Message entity and the respective DB fields.
1 parent 3f07415 commit 7444c44

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
44
Exclamation symbols (:exclamation:) note something of importance e.g. breaking changes. Click them to learn more.
55

66
## [Unreleased]
7+
:exclamation: After updating to this version, you will need to execute the [SQL migration script][unreleased-sql-migration] on your database.
78
### Added
89
- `getIsMember()` method to `ChatMember` entity.
10+
- `getForwardSenderName()` method to `Message` entity.
11+
- `forward_sender_name` (and forgotten `forward_signature`) DB fields.
912
### Changed
1013
### Deprecated
1114
### Removed
@@ -250,6 +253,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
250253
### Deprecated
251254
- Move `hideKeyboard` to `removeKeyboard`.
252255

256+
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/develop/utils/db-schema-update/unreleased.sql
253257
[0.55.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.54.1-0.55.0.sql
254258
[0.55.0-bc-move-animation-out-of-games-namespace]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#move-animation-out-of-games-namespace
255259
[0.54.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.53.0-0.54.0.sql

src/DB.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,15 +828,17 @@ public static function insertMessageRequest(Message $message)
828828
INSERT IGNORE INTO `' . TB_MESSAGE . '`
829829
(
830830
`id`, `user_id`, `chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
831-
`forward_date`, `reply_to_chat`, `reply_to_message`, `media_group_id`, `text`, `entities`, `audio`, `document`,
831+
`forward_signature`, `forward_sender_name`, `forward_date`,
832+
`reply_to_chat`, `reply_to_message`, `media_group_id`, `text`, `entities`, `audio`, `document`,
832833
`animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
833834
`location`, `venue`, `new_chat_members`, `left_chat_member`,
834835
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
835836
`supergroup_chat_created`, `channel_chat_created`,
836837
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`, `connected_website`, `passport_data`
837838
) VALUES (
838839
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
839-
:forward_date, :reply_to_chat, :reply_to_message, :media_group_id, :text, :entities, :audio, :document,
840+
:forward_signature, :forward_sender_name, :forward_date,
841+
:reply_to_chat, :reply_to_message, :media_group_id, :text, :entities, :audio, :document,
840842
:animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
841843
:location, :venue, :new_chat_members, :left_chat_member,
842844
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
@@ -867,6 +869,8 @@ public static function insertMessageRequest(Message $message)
867869
$sth->bindValue(':forward_from', $forward_from);
868870
$sth->bindValue(':forward_from_chat', $forward_from_chat);
869871
$sth->bindValue(':forward_from_message_id', $message->getForwardFromMessageId());
872+
$sth->bindValue(':forward_signature', $message->getForwardSignature());
873+
$sth->bindValue(':forward_sender_name', $message->getForwardSenderName());
870874
$sth->bindValue(':forward_date', $forward_date);
871875

872876
$reply_to_chat_id = null;

src/Entities/Message.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @method Chat getForwardFromChat() Optional. For messages forwarded from a channel, information about the original channel
2929
* @method int getForwardFromMessageId() Optional. For forwarded channel posts, identifier of the original message in the channel
3030
* @method string getForwardSignature() Optional. For messages forwarded from channels, signature of the post author if present
31+
* @method string getForwardSenderName() Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages
3132
* @method int getForwardDate() Optional. For forwarded messages, date the original message was sent in Unix time
3233
* @method Message getReplyToMessage() Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
3334
* @method int getEditDate() Optional. Date the message was last edited in Unix time

structure.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ CREATE TABLE IF NOT EXISTS `message` (
7373
`forward_from` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, sender of the original message',
7474
`forward_from_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier, chat the original message belongs to',
7575
`forward_from_message_id` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier of the original message in the channel',
76+
`forward_signature` TEXT NULL DEFAULT NULL COMMENT 'For messages forwarded from channels, signature of the post author if present',
77+
`forward_sender_name` TEXT NULL DEFAULT NULL COMMENT 'Sender''s name for messages forwarded from users who disallow adding a link to their account in forwarded messages',
7678
`forward_date` timestamp NULL DEFAULT NULL COMMENT 'date the original message was sent in timestamp format',
7779
`reply_to_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier',
7880
`reply_to_message` bigint UNSIGNED DEFAULT NULL COMMENT 'Message that this message is reply to',
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE `message` ADD COLUMN `forward_signature` TEXT NULL DEFAULT NULL COMMENT 'For messages forwarded from channels, signature of the post author if present' AFTER `forward_from_message_id`;
2+
ALTER TABLE `message` ADD COLUMN `forward_sender_name` TEXT NULL DEFAULT NULL COMMENT 'Sender''s name for messages forwarded from users who disallow adding a link to their account in forwarded messages' AFTER `forward_signature`;

0 commit comments

Comments
 (0)