Skip to content

Commit 7ba27d1

Browse files
committed
.
1 parent a406046 commit 7ba27d1

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

TMessagesProj/src/main/java/org/telegram/messenger/forkgram/AsCopyUtils.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ fun PerformForwardFromMyName(
6363
sendingMessageObjects: ArrayList<MessageObject>,
6464
currentAccount: Int,
6565
parentFragment: BaseFragment?,
66-
notify: Boolean) {
66+
notify: Boolean,
67+
monoForumPeerId: Long = 0L) {
6768

6869
val queue = ArrayList<() -> Unit>();
6970
val saveOriginalCaptions = (text == null)
@@ -101,6 +102,7 @@ fun PerformForwardFromMyName(
101102
parentFragment,
102103
copyText,
103104
notify,
105+
monoForumPeerId,
104106
deque)
105107
}
106108
}
@@ -122,7 +124,7 @@ fun PerformForwardFromMyName(
122124
val copyText = currentReplaceText();
123125
queue.add {
124126
val instance = SendMessagesHelper.getInstance(currentAccount);
125-
instance.processForwardFromMyName(copyMsg, key, 0, topicId, null, copyText, notify, topicId)
127+
instance.processForwardFromMyName(copyMsg, key, 0, 0, null, copyText, notify, topicId, monoForumPeerId)
126128
deque();
127129
}
128130
}
@@ -140,7 +142,8 @@ fun GroupItemsIntoAlbum(
140142
sendingMessageObjects: ArrayList<MessageObject>,
141143
currentAccount: Int,
142144
parentFragment: BaseFragment?,
143-
notify: Boolean) {
145+
notify: Boolean,
146+
monoForumPeerId: Long = 0L) {
144147
if (sendingMessageObjects.isEmpty()) {
145148
return;
146149
}
@@ -153,7 +156,7 @@ fun GroupItemsIntoAlbum(
153156
val objectsToDelay = sub(objectsToSend.size, sendingMessageObjects.size);
154157

155158
val finish = {
156-
GroupItemsIntoAlbum(key, reply, text, objectsToDelay, currentAccount, parentFragment, notify)
159+
GroupItemsIntoAlbum(key, reply, text, objectsToDelay, currentAccount, parentFragment, notify, monoForumPeerId)
157160
};
158161

159162
SendItemsAsAlbum(
@@ -164,6 +167,7 @@ fun GroupItemsIntoAlbum(
164167
parentFragment,
165168
text,
166169
notify,
170+
monoForumPeerId,
167171
finish)
168172
}
169173

@@ -211,12 +215,13 @@ fun SendItemsAsAlbum(
211215
fragment: BaseFragment?,
212216
replaceText: String?,
213217
notify: Boolean,
218+
monoForumPeerId: Long = 0L,
214219
finish: () -> Unit) {
215220
if (peer == 0L || messages.size > 10 || messages.isEmpty()) {
216221
return
217222
}
218223
val accountInstance = AccountInstance.getInstance(currentAccount)
219-
val lower_id = peer
224+
val lower_id = if (monoForumPeerId != 0L) monoForumPeerId else peer
220225
val sendToPeer: InputPeer =
221226
(if (lower_id != 0L) accountInstance.messagesController.getInputPeer(lower_id)
222227
else null)
@@ -306,7 +311,7 @@ fun SendItemsAsAlbum(
306311
showToast("Sorry, something went wrong.");
307312
return@handleMessages
308313
}
309-
SendItemsAsAlbum(currentAccount, messages, peer, reply, fragment, replaceText, notify, finish)
314+
SendItemsAsAlbum(currentAccount, messages, peer, reply, fragment, replaceText, notify, monoForumPeerId, finish)
310315
}
311316

312317
ForkApi.TLRPCMessages(currentAccount, messages, handleMessages);

TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,11 +1809,17 @@ public int getFillColor() {
18091809
: "")
18101810
: null;
18111811
if (hasComment && !nonText) {
1812-
SendMessagesHelper.getInstance(account).sendMessage(SendMessagesHelper.SendMessageParams.of(
1812+
boolean isMonoForum = MessagesController.getInstance(account).isMonoForum(key);
1813+
long monoForumPeerId = keyTopic != null && isMonoForum ? DialogObject.getPeerDialogId(keyTopic.from_id) : 0;
1814+
MessageObject replyTopMsg = keyTopic != null && !isMonoForum ? new MessageObject(account, keyTopic.topicStartMessage, false, false) : null;
1815+
if (replyTopMsg != null) {
1816+
replyTopMsg.isTopicMainMessage = true;
1817+
}
1818+
SendMessagesHelper.SendMessageParams params = SendMessagesHelper.SendMessageParams.of(
18131819
commentTextView.getText().toString(),
18141820
key,
1815-
null,
1816-
null,
1821+
replyTopMsg,
1822+
replyTopMsg,
18171823
null,
18181824
true,
18191825
null,
@@ -1822,29 +1828,41 @@ public int getFillColor() {
18221828
notify,
18231829
0,
18241830
null,
1825-
false));
1831+
false);
1832+
params.monoForumPeer = monoForumPeerId;
1833+
SendMessagesHelper.getInstance(account).sendMessage(params);
18261834
}
18271835
if (groupAnyItems) {
1836+
boolean isMonoForum = MessagesController.getInstance(account).isMonoForum(key);
1837+
long monoForumPeerId = keyTopic != null && isMonoForum ? DialogObject.getPeerDialogId(keyTopic.from_id) : 0;
1838+
int replyId = AsCopy.TakeReplyToDraft(key, keyTopic, account, true);
1839+
if (replyId == 0 && keyTopic != null && !isMonoForum) {
1840+
replyId = keyTopic.id;
1841+
}
18281842
AsCopy.GroupItemsIntoAlbum(
18291843
key,
1830-
AsCopy.TakeReplyToDraft(key, keyTopic, account, true),
1844+
replyId,
18311845
maybeReplaceText,
18321846
sendingMessageObjects,
18331847
account,
18341848
parentFragment,
1835-
notify);
1849+
notify,
1850+
monoForumPeerId);
18361851
onSend(selectedDialogs, selectedDialogs.size(), keyTopic, info);
18371852
dismiss();
18381853
return;
18391854
}
1855+
boolean isMonoForum = MessagesController.getInstance(account).isMonoForum(key);
1856+
long monoForumPeerId = keyTopic != null && isMonoForum ? DialogObject.getPeerDialogId(keyTopic.from_id) : 0;
18401857
AsCopy.PerformForwardFromMyName(
18411858
key,
18421859
keyTopic,
18431860
maybeReplaceText,
18441861
sendingMessageObjects,
18451862
account,
18461863
parentFragment,
1847-
notify);
1864+
notify,
1865+
monoForumPeerId);
18481866
}
18491867
onSend(selectedDialogs, selectedDialogs.size(), selectedDialogTopics.get(selectedDialogs.valueAt(0)), info);
18501868
} else {

0 commit comments

Comments
 (0)