Browse Source

sending dm media shares with exact child

https://t.me/barinsta_app/21890
renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
3f6ed5f78b
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 4
      app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
  2. 3
      app/src/main/java/awais/instagrabber/managers/DirectMessagesManager.kt
  3. 8
      app/src/main/java/awais/instagrabber/repositories/requests/directmessages/MediaShareBroadcastOptions.kt
  4. 10
      app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.kt
  5. 3
      app/src/main/java/awais/instagrabber/webservices/DirectMessagesService.kt

4
app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java

@ -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);
} }

3
app/src/main/java/awais/instagrabber/managers/DirectMessagesManager.kt

@ -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(

8
app/src/main/java/awais/instagrabber/repositories/requests/directmessages/MediaShareBroadcastOptions.kt

@ -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()
} }

10
app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.kt

@ -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)
} }
} }

3
app/src/main/java/awais/instagrabber/webservices/DirectMessagesService.kt

@ -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,

Loading…
Cancel
Save