1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +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) {
Toast.makeText(context, R.string.sending, Toast.LENGTH_SHORT).show();
}
viewModel.shareDm((RankedRecipient) result);
viewModel.shareDm((RankedRecipient) result, sliderPosition);
} else if ((result instanceof Set)) {
try {
// 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();
}
//noinspection unchecked
viewModel.shareDm((Set<RankedRecipient>) result);
viewModel.shareDm((Set<RankedRecipient>) result, sliderPosition);
} catch (Exception e) {
Log.e(TAG, "share: ", e);
}

View File

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

View File

@ -5,12 +5,16 @@ import awais.instagrabber.models.enums.BroadcastItemType
class MediaShareBroadcastOptions(
clientContext: String,
threadIdsOrUserIds: ThreadIdsOrUserIds,
val mediaId: String
val mediaId: String,
val childId: String?
) : BroadcastOptions(
clientContext,
threadIdsOrUserIds,
BroadcastItemType.MEDIA_SHARE
) {
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
}
fun shareDm(result: RankedRecipient) {
fun shareDm(result: RankedRecipient, child: Int) {
if (messageManager == null) {
messageManager = DirectMessagesManager
}
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) {
messageManager = DirectMessagesManager
}
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,
threadIdsOrUserIds: ThreadIdsOrUserIds,
mediaId: String,
childId: String?,
): DirectThreadBroadcastResponse =
broadcast(csrfToken, userId, deviceUuid, MediaShareBroadcastOptions(clientContext, threadIdsOrUserIds, mediaId))
broadcast(csrfToken, userId, deviceUuid, MediaShareBroadcastOptions(clientContext, threadIdsOrUserIds, mediaId, childId))
suspend fun broadcastProfile(
csrfToken: String,