mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-12 17:57:29 +00:00
share story via dm (backend)
This commit is contained in:
parent
06f679608c
commit
1bba8dc065
@ -102,8 +102,8 @@ object DirectMessagesManager {
|
||||
data.postValue(loading(null))
|
||||
scope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
if (itemType == BroadcastItemType.MEDIA_SHARE)
|
||||
directMessagesRepository.broadcastMediaShare(
|
||||
when (itemType) {
|
||||
BroadcastItemType.MEDIA_SHARE -> directMessagesRepository.broadcastMediaShare(
|
||||
csrfToken,
|
||||
viewerId,
|
||||
deviceUuid,
|
||||
@ -112,8 +112,7 @@ object DirectMessagesManager {
|
||||
mediaId,
|
||||
secondId
|
||||
)
|
||||
if (itemType == BroadcastItemType.PROFILE)
|
||||
directMessagesRepository.broadcastProfile(
|
||||
BroadcastItemType.PROFILE -> directMessagesRepository.broadcastProfile(
|
||||
csrfToken,
|
||||
viewerId,
|
||||
deviceUuid,
|
||||
@ -121,6 +120,16 @@ object DirectMessagesManager {
|
||||
ThreadIdsOrUserIds(threadIds, userIds),
|
||||
mediaId
|
||||
)
|
||||
BroadcastItemType.STORY -> directMessagesRepository.broadcastStory(
|
||||
csrfToken,
|
||||
viewerId,
|
||||
deviceUuid,
|
||||
UUID.randomUUID().toString(),
|
||||
ThreadIdsOrUserIds(threadIds, userIds),
|
||||
mediaId,
|
||||
secondId!!
|
||||
)
|
||||
}
|
||||
data.postValue(success(Any()))
|
||||
callback?.invoke()
|
||||
} catch (e: Exception) {
|
||||
@ -132,6 +141,42 @@ object DirectMessagesManager {
|
||||
return data
|
||||
}
|
||||
|
||||
fun replyToStory(
|
||||
recipientId: Long?,
|
||||
reelId: String?,
|
||||
mediaId: String?,
|
||||
text: String,
|
||||
scope: CoroutineScope
|
||||
): LiveData<Resource<Any?>> {
|
||||
Log.d("austin_debug", "replying")
|
||||
val data = MutableLiveData<Resource<Any?>>()
|
||||
data.postValue(loading(null))
|
||||
if (recipientId == null || reelId == null || mediaId == null) {
|
||||
data.postValue(error("arguments are null", null))
|
||||
return data
|
||||
}
|
||||
scope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
directMessagesRepository.broadcastStoryReply(
|
||||
csrfToken,
|
||||
viewerId,
|
||||
deviceUuid,
|
||||
ThreadIdsOrUserIds.Companion.ofOneUser(recipientId.toString(10)),
|
||||
text,
|
||||
mediaId,
|
||||
reelId
|
||||
)
|
||||
inboxManager.refresh(scope)
|
||||
data.postValue(success(null))
|
||||
}
|
||||
catch (e: Exception) {
|
||||
Log.e(TAG, "story reply: ", e)
|
||||
data.postValue(error(e.message, null))
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
init {
|
||||
val cookie = Utils.settingsHelper.getString(Constants.COOKIE)
|
||||
viewerId = getUserIdFromCookie(cookie)
|
||||
|
@ -7,7 +7,7 @@ class StoryReplyBroadcastOptions(
|
||||
threadIdsOrUserIds: ThreadIdsOrUserIds,
|
||||
val text: String,
|
||||
val mediaId: String,
|
||||
val reelId: String // or user id, usually same
|
||||
val reelId: String
|
||||
) : BroadcastOptions(clientContext, threadIdsOrUserIds, BroadcastItemType.REELSHARE) {
|
||||
override val formMap: Map<String, String>
|
||||
get() = mapOf(
|
||||
|
@ -187,6 +187,17 @@ open class DirectMessagesRepository(private val service: DirectMessagesService)
|
||||
): DirectThreadBroadcastResponse =
|
||||
broadcast(csrfToken, userId, deviceUuid, ProfileBroadcastOptions(clientContext, threadIdsOrUserIds, profileId))
|
||||
|
||||
suspend fun broadcastStory(
|
||||
csrfToken: String,
|
||||
userId: Long,
|
||||
deviceUuid: String,
|
||||
clientContext: String,
|
||||
threadIdsOrUserIds: ThreadIdsOrUserIds,
|
||||
mediaId: String,
|
||||
reelId: String,
|
||||
): DirectThreadBroadcastResponse =
|
||||
broadcast(csrfToken, userId, deviceUuid, StoryBroadcastOptions(clientContext, threadIdsOrUserIds, mediaId, reelId))
|
||||
|
||||
private suspend fun broadcast(
|
||||
csrfToken: String,
|
||||
userId: Long,
|
||||
|
Loading…
Reference in New Issue
Block a user