Skip to content

Commit

Permalink
fix: entity lost in merge message
Browse files Browse the repository at this point in the history
Signed-off-by: Next Alone <[email protected]>
  • Loading branch information
NextAlone committed Nov 25, 2023
1 parent 3d4a315 commit 25b4d5f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3197,7 +3197,8 @@ public void onItemClick(final int id) {
StringBuilder str = new StringBuilder();
ArrayList<Integer> toDeleteMessagesIds = new ArrayList<>();
MessageObject toEdit = null;

ArrayList<TLRPC.MessageEntity> entities;
entities = new ArrayList<>();
for (int a = 1; a >= 0; a--) {
ArrayList<Integer> ids = new ArrayList<>();
for (int b = 0; b < selectedMessagesIds[a].size(); b++) {
Expand All @@ -3216,7 +3217,21 @@ public void onItemClick(final int id) {
continue;
}
if (str.length() != 0) {
str.append(" ");
str.append(" ");
}
if (messageObject.messageOwner.entities != null && !messageObject.messageOwner.entities.isEmpty()) {
for (TLRPC.MessageEntity entity : messageObject.messageOwner.entities) {
if (entity instanceof TLRPC.TL_messageEntityMentionName) {
TLRPC.TL_inputMessageEntityMentionName mention = new TLRPC.TL_inputMessageEntityMentionName();
mention.length = entity.length;
mention.offset = str.length() + entity.offset;
mention.user_id = getMessagesController().getInputUser(((TLRPC.TL_messageEntityMentionName) entity).user_id);
entities.add(mention);
} else {
entity.offset += str.length();
entities.add(entity);
}
}
}
str.append(messageObject.messageText);
if (messageObject.getSenderId() == UserConfig.getInstance(currentAccount).getClientUserId()) {
Expand All @@ -3231,11 +3246,13 @@ public void onItemClick(final int id) {
if (str.length() != 0 && toEdit != null) {
if (toEdit.canEditMessage(currentChat)) {
toEdit.editingMessage = str;
toEdit.editingMessageEntities = entities;
SendMessagesHelper.getInstance(currentAccount).editMessage(toEdit, null, null, null, null, null, false, toEdit.hasMediaSpoilers(), null);
} else {
MessageObject replyTo = toEdit.replyMessageObject;
toDeleteMessagesIds.add(toEdit.getId());
SendMessagesHelper.getInstance(currentAccount).sendMessage(SendMessagesHelper.SendMessageParams.of(str.toString(), dialog_id, replyTo, getThreadMessage(), null, false, null, null, null, true, 0, null, false));
SendMessagesHelper.getInstance(currentAccount)
.sendMessage(SendMessagesHelper.SendMessageParams.of(str.toString(), dialog_id, replyTo, getThreadMessage(), null, false, entities, null, null, true, 0, null, false));
}
MessagesController.getInstance(currentAccount).deleteMessages(toDeleteMessagesIds, null, null, dialog_id, true, false);
}
Expand Down

0 comments on commit 25b4d5f

Please sign in to comment.