1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00

sending dm media shares with exact child

https://t.me/barinsta_app/21890
This commit is contained in:
Austin Huang 2021-06-28 15:29:37 -04:00
parent bf1a05a38c
commit 3f6ed5f78b
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
5 changed files with 18 additions and 10 deletions

View File

@ -152,7 +152,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
if (context != null) { if (context != null) {
Toast.makeText(context, R.string.sending, Toast.LENGTH_SHORT).show(); Toast.makeText(context, R.string.sending, Toast.LENGTH_SHORT).show();
} }
viewModel.shareDm((RankedRecipient) result); viewModel.shareDm((RankedRecipient) result, sliderPosition);
} else if ((result instanceof Set)) { } else if ((result instanceof Set)) {
try { try {
// Log.d(TAG, "result: " + result); // Log.d(TAG, "result: " + result);
@ -161,7 +161,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
Toast.makeText(context, R.string.sending, Toast.LENGTH_SHORT).show(); Toast.makeText(context, R.string.sending, Toast.LENGTH_SHORT).show();
} }
//noinspection unchecked //noinspection unchecked
viewModel.shareDm((Set<RankedRecipient>) result); viewModel.shareDm((Set<RankedRecipient>) result, sliderPosition);
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "share: ", e); Log.e(TAG, "share: ", e);
} }

View File

@ -107,7 +107,8 @@ object DirectMessagesManager {
deviceUuid, deviceUuid,
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
ThreadIdsOrUserIds(threadIds, userIds), ThreadIdsOrUserIds(threadIds, userIds),
mediaId mediaId,
secondId
) )
if (itemType == BroadcastItemType.PROFILE) if (itemType == BroadcastItemType.PROFILE)
DirectMessagesService.broadcastProfile( DirectMessagesService.broadcastProfile(

View File

@ -5,12 +5,16 @@ import awais.instagrabber.models.enums.BroadcastItemType
class MediaShareBroadcastOptions( class MediaShareBroadcastOptions(
clientContext: String, clientContext: String,
threadIdsOrUserIds: ThreadIdsOrUserIds, threadIdsOrUserIds: ThreadIdsOrUserIds,
val mediaId: String val mediaId: String,
val childId: String?
) : BroadcastOptions( ) : BroadcastOptions(
clientContext, clientContext,
threadIdsOrUserIds, threadIdsOrUserIds,
BroadcastItemType.MEDIA_SHARE BroadcastItemType.MEDIA_SHARE
) { ) {
override val formMap: Map<String, String> override val formMap: Map<String, String>
get() = mapOf("media_id" to mediaId) get() = listOfNotNull(
"media_id" to mediaId,
if (childId != null) "carousel_share_child_media_id" to childId else null
).toMap()
} }

View File

@ -331,19 +331,21 @@ class PostViewV2ViewModel : ViewModel() {
return data return data
} }
fun shareDm(result: RankedRecipient) { fun shareDm(result: RankedRecipient, child: Int) {
if (messageManager == null) { if (messageManager == null) {
messageManager = DirectMessagesManager messageManager = DirectMessagesManager
} }
val mediaId = media.id ?: return val mediaId = media.id ?: return
messageManager?.sendMedia(result, mediaId, null, BroadcastItemType.MEDIA_SHARE, viewModelScope) val childId = if (child == -1) null else media.carouselMedia?.get(child)?.id
messageManager?.sendMedia(result, mediaId, childId, BroadcastItemType.MEDIA_SHARE, viewModelScope)
} }
fun shareDm(recipients: Set<RankedRecipient>) { fun shareDm(recipients: Set<RankedRecipient>, child: Int) {
if (messageManager == null) { if (messageManager == null) {
messageManager = DirectMessagesManager messageManager = DirectMessagesManager
} }
val mediaId = media.id ?: return val mediaId = media.id ?: return
messageManager?.sendMedia(recipients, mediaId, null, BroadcastItemType.MEDIA_SHARE, viewModelScope) val childId = if (child == -1) null else media.carouselMedia?.get(child)?.id
messageManager?.sendMedia(recipients, mediaId, childId, BroadcastItemType.MEDIA_SHARE, viewModelScope)
} }
} }

View File

@ -164,8 +164,9 @@ object DirectMessagesService {
clientContext: String, clientContext: String,
threadIdsOrUserIds: ThreadIdsOrUserIds, threadIdsOrUserIds: ThreadIdsOrUserIds,
mediaId: String, mediaId: String,
childId: String?,
): DirectThreadBroadcastResponse = ): DirectThreadBroadcastResponse =
broadcast(csrfToken, userId, deviceUuid, MediaShareBroadcastOptions(clientContext, threadIdsOrUserIds, mediaId)) broadcast(csrfToken, userId, deviceUuid, MediaShareBroadcastOptions(clientContext, threadIdsOrUserIds, mediaId, childId))
suspend fun broadcastProfile( suspend fun broadcastProfile(
csrfToken: String, csrfToken: String,