Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img src="https://img.shields.io/github/stars/monogram-android/monogram" width="120">
</a>
<img src="https://img.shields.io/badge/Kotlin-2.0+-blue.svg?logo=kotlin" width="130">
<img src="https://img.shields.io/badge/TDLib-1.8.65-blue" width="120">
<img src="https://img.shields.io/badge/TDLib-1.8.66-blue" width="120">
<img src="https://img.shields.io/badge/Status-Active_Development-orange" width="170">
<a href="https://boosty.to/monogram">
<img src="https://img.shields.io/badge/Boosty-Support_the_project-ff6f61?logo=boosty&logoColor=white" width="200">
Expand Down
2 changes: 1 addition & 1 deletion README_ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img src="https://img.shields.io/github/stars/monogram-android/monogram" width="120">
</a>
<img src="https://img.shields.io/badge/Kotlin-2.0+-blue.svg?logo=kotlin" width="130">
<img src="https://img.shields.io/badge/TDLib-1.8.65-blue" width="120">
<img src="https://img.shields.io/badge/TDLib-1.8.66-blue" width="120">
<img src="https://img.shields.io/badge/Status-Active_Development-orange" width="170">
<a href="https://boosty.to/monogram">
<img src="https://img.shields.io/badge/Boosty-Support_the_project-ff6f61?logo=boosty&logoColor=white" width="200">
Expand Down
2 changes: 1 addition & 1 deletion README_KOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img src="https://img.shields.io/github/stars/monogram-android/monogram" width="120">
</a>
<img src="https://img.shields.io/badge/Kotlin-2.0+-blue.svg?logo=kotlin" width="130">
<img src="https://img.shields.io/badge/TDLib-1.8.65-blue" width="120">
<img src="https://img.shields.io/badge/TDLib-1.8.66-blue" width="120">
<img src="https://img.shields.io/badge/Status-Active_Development-orange" width="170">
<a href="https://boosty.to/monogram">
<img src="https://img.shields.io/badge/Boosty-Support_the_project-ff6f61?logo=boosty&logoColor=white" width="200">
Expand Down
2 changes: 1 addition & 1 deletion README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img src="https://img.shields.io/github/stars/monogram-android/monogram" width="120">
</a>
<img src="https://img.shields.io/badge/Kotlin-2.0+-blue.svg?logo=kotlin" width="130">
<img src="https://img.shields.io/badge/TDLib-1.8.65-blue" width="120">
<img src="https://img.shields.io/badge/TDLib-1.8.66-blue" width="120">
<img src="https://img.shields.io/badge/Status-Active_Development-orange" width="170">
<a href="https://boosty.to/monogram">
<img src="https://img.shields.io/badge/Boosty-Support_the_project-ff6f61?logo=boosty&logoColor=white" width="200">
Expand Down
2 changes: 1 addition & 1 deletion README_TR.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img src="https://img.shields.io/github/stars/monogram-android/monogram" width="120">
</a>
<img src="https://img.shields.io/badge/Kotlin-2.0+-blue.svg?logo=kotlin" width="130">
<img src="https://img.shields.io/badge/TDLib-1.8.65-blue" width="120">
<img src="https://img.shields.io/badge/TDLib-1.8.66-blue" width="120">
<img src="https://img.shields.io/badge/Durum-Aktif_Geliştirme-orange" width="170">
<a href="https://boosty.to/monogram">
<img src="https://img.shields.io/badge/Boosty-Projeyi_Destekle-ff6f61?logo=boosty&logoColor=white" width="200">
Expand Down
2 changes: 1 addition & 1 deletion README_UR.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img src="https://img.shields.io/github/stars/monogram-android/monogram" width="120">
</a>
<img src="https://img.shields.io/badge/Kotlin-2.0+-blue.svg?logo=kotlin" width="130">
<img src="https://img.shields.io/badge/TDLib-1.8.65-blue" width="120">
<img src="https://img.shields.io/badge/TDLib-1.8.66-blue" width="120">
<img src="https://img.shields.io/badge/Status-Active_Development-orange" width="170">
<a href="https://boosty.to/monogram">
<img src="https://img.shields.io/badge/Boosty-Support_the_project-ff6f61?logo=boosty&logoColor=white" width="200">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface LinkRemoteDataSource {
suspend fun searchPublicChat(username: String): TdApi.Chat?
suspend fun checkChatInviteLink(inviteLink: String): TdApi.ChatInviteLinkInfo?
suspend fun joinChatByInviteLink(inviteLink: String): TdApi.ChatJoinResult?
suspend fun getGuardBotWebAppUrl(queryId: Long): TdApi.WebAppUrl?
suspend fun getMe(): TdApi.User?
suspend fun createPrivateChat(userId: Long): TdApi.Chat?
suspend fun searchUserByPhoneNumber(phoneNumber: String): TdApi.User?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.monogram.domain.models.webapp.WebAppInfoModel
import org.monogram.domain.repository.ChecklistDraft
import org.monogram.domain.repository.OlderMessagesPage
import org.monogram.domain.repository.ReadUpdate
import org.monogram.domain.repository.RichTextParseMode
import org.monogram.domain.repository.SearchChatMessagesResult

interface MessageRemoteDataSource : DraftLinkPreviewRemoteDataSource {
Expand Down Expand Up @@ -83,7 +84,8 @@ interface MessageRemoteDataSource : DraftLinkPreviewRemoteDataSource {
threadId: Long?,
sendOptions: MessageSendOptions,
isRtl: Boolean?,
detectAutomaticBlocks: Boolean
detectAutomaticBlocks: Boolean,
parseMode: RichTextParseMode = RichTextParseMode.Markdown
): TdApi.Message?

suspend fun sendPhoto(
Expand Down Expand Up @@ -191,7 +193,8 @@ interface MessageRemoteDataSource : DraftLinkPreviewRemoteDataSource {
messageId: Long,
markdown: String,
isRtl: Boolean?,
detectAutomaticBlocks: Boolean
detectAutomaticBlocks: Boolean,
parseMode: RichTextParseMode = RichTextParseMode.Markdown
): TdApi.Message?
suspend fun editMessageCaption(chatId: Long, messageId: Long, caption: String, entities: List<MessageEntity>): TdApi.Message?
suspend fun getFullRichMessage(chatId: Long, messageId: Long): TdApi.RichMessage?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ class TdLinkRemoteDataSource(
override suspend fun joinChatByInviteLink(inviteLink: String): TdApi.ChatJoinResult? =
coRunCatching { gateway.execute(TdApi.JoinChatByInviteLink(inviteLink)) }.getOrNull()

override suspend fun getGuardBotWebAppUrl(queryId: Long): TdApi.WebAppUrl? =
coRunCatching {
gateway.execute(
TdApi.GetGuardBotWebAppUrl(
queryId,
buildDefaultWebAppOpenParameters(theme = null)
)
)
}.getOrNull()

override suspend fun getMe(): TdApi.User? =
coRunCatching { gateway.execute(TdApi.GetMe()) }.getOrNull()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ import org.monogram.data.compat.buildInputDocument
import org.monogram.data.compat.buildInputPhoto
import org.monogram.data.compat.buildInputPollOption
import org.monogram.data.compat.buildInputPollTypeQuiz
import org.monogram.data.compat.buildInputSticker
import org.monogram.data.compat.buildInputVideo
import org.monogram.data.compat.buildInputVideoNote
import org.monogram.data.compat.buildInputVoiceNote
import org.monogram.data.compat.buildRichMessageSourceHtml
import org.monogram.data.compat.buildRichMessageSourceMarkdown
import org.monogram.data.compat.extractTextDraft
import org.monogram.data.gateway.TdLibException
import org.monogram.data.gateway.TelegramGateway
import org.monogram.data.infra.FileDownloadQueue
import org.monogram.data.infra.FileUpdateHandler
import org.monogram.data.mapper.MessageMapper
import org.monogram.data.mapper.WebPageMapper
import org.monogram.data.mapper.toApi
import org.monogram.data.repository.DraftLinkPreviewResolver
import org.monogram.domain.models.DraftLinkPreview
import org.monogram.domain.models.DraftLinkPreviewRequest
Expand All @@ -59,6 +63,7 @@ import org.monogram.domain.repository.ChecklistDraft
import org.monogram.domain.repository.OlderMessagesPage
import org.monogram.domain.repository.PollRepository
import org.monogram.domain.repository.ReadUpdate
import org.monogram.domain.repository.RichTextParseMode
import org.monogram.domain.repository.SearchChatMessagesResult
import org.monogram.domain.repository.UserRepository
import java.util.concurrent.ConcurrentHashMap
Expand Down Expand Up @@ -827,10 +832,12 @@ class TdMessageRemoteDataSource(
threadId: Long?,
sendOptions: MessageSendOptions,
isRtl: Boolean?,
detectAutomaticBlocks: Boolean
detectAutomaticBlocks: Boolean,
parseMode: RichTextParseMode
): TdApi.Message? {
val content = buildInputMessageRichMessage(
markdown = markdown,
parseMode = parseMode,
isRtl = isRtl ?: shouldRenderRtl(markdown),
detectAutomaticBlocks = detectAutomaticBlocks,
clearDraft = true
Expand Down Expand Up @@ -1013,9 +1020,8 @@ class TdMessageRemoteDataSource(

override suspend fun sendSticker(chatId: Long, stickerPath: String, replyToMsgId: Long?, threadId: Long?): TdApi.Message? {
val content = TdApi.InputMessageSticker().apply {
this.sticker = TdApi.InputFileLocal(stickerPath)
this.width = 512
this.height = 512
sticker = buildInputSticker(TdApi.InputFileLocal(stickerPath), 512, 512)
emoji = ""
}
val replyTo = if (replyToMsgId != null && replyToMsgId != 0L) TdApi.InputMessageReplyToMessage(replyToMsgId, null, 0, "") else null
val topicId = resolveTopicId(chatId, threadId)
Expand Down Expand Up @@ -1161,9 +1167,7 @@ class TdMessageRemoteDataSource(
threadId: Long?
): TdApi.Message? {
val content = TdApi.InputMessageVideoNote().apply {
this.videoNote = TdApi.InputFileLocal(videoPath)
this.duration = duration
this.length = length
videoNote = buildInputVideoNote(TdApi.InputFileLocal(videoPath), duration, length)
}
val replyTo = if (replyToMsgId != null && replyToMsgId != 0L) TdApi.InputMessageReplyToMessage(replyToMsgId, null, 0, "") else null
val topicId = resolveTopicId(chatId, threadId)
Expand All @@ -1187,9 +1191,7 @@ class TdMessageRemoteDataSource(
threadId: Long?
): TdApi.Message? {
val content = TdApi.InputMessageVoiceNote().apply {
this.voiceNote = TdApi.InputFileLocal(voicePath)
this.duration = duration
this.waveform = waveform
voiceNote = buildInputVoiceNote(TdApi.InputFileLocal(voicePath), duration, waveform)
}
val replyTo = if (replyToMsgId != null && replyToMsgId != 0L) TdApi.InputMessageReplyToMessage(replyToMsgId, null, 0, "") else null
val topicId = resolveTopicId(chatId, threadId)
Expand Down Expand Up @@ -1259,10 +1261,12 @@ class TdMessageRemoteDataSource(
messageId: Long,
markdown: String,
isRtl: Boolean?,
detectAutomaticBlocks: Boolean
detectAutomaticBlocks: Boolean,
parseMode: RichTextParseMode
): TdApi.Message? {
val content = buildInputMessageRichMessage(
markdown = markdown,
parseMode = parseMode,
isRtl = isRtl ?: shouldRenderRtl(markdown),
detectAutomaticBlocks = detectAutomaticBlocks,
clearDraft = false
Expand Down Expand Up @@ -1352,16 +1356,17 @@ class TdMessageRemoteDataSource(

private fun buildInputMessageRichMessage(
markdown: String,
parseMode: RichTextParseMode,
isRtl: Boolean,
detectAutomaticBlocks: Boolean,
clearDraft: Boolean
): TdApi.InputMessageRichMessage {
val source = when (parseMode) {
RichTextParseMode.Markdown -> buildRichMessageSourceMarkdown(markdown)
RichTextParseMode.Html -> buildRichMessageSourceHtml(markdown)
}
return TdApi.InputMessageRichMessage(
TdApi.InputRichMessage(
TdApi.RichMessageSourceMarkdown(markdown),
isRtl,
detectAutomaticBlocks
),
TdApi.InputRichMessage(source, isRtl, detectAutomaticBlocks),
clearDraft
)
}
Expand Down Expand Up @@ -1427,11 +1432,14 @@ class TdMessageRemoteDataSource(
is MessageEntityType.Mention -> TdApi.TextEntityTypeMention()
is MessageEntityType.TextMention -> TdApi.TextEntityTypeMentionName(value.userId)
is MessageEntityType.Hashtag -> TdApi.TextEntityTypeHashtag()
is MessageEntityType.Cashtag -> TdApi.TextEntityTypeCashtag()
is MessageEntityType.BotCommand -> TdApi.TextEntityTypeBotCommand()
is MessageEntityType.Url -> TdApi.TextEntityTypeUrl()
is MessageEntityType.Email -> TdApi.TextEntityTypeEmailAddress()
is MessageEntityType.PhoneNumber -> TdApi.TextEntityTypePhoneNumber()
is MessageEntityType.BankCardNumber -> TdApi.TextEntityTypeBankCardNumber()
is MessageEntityType.DateTime -> TdApi.TextEntityTypeDateTime(value.unixTime, null)
is MessageEntityType.MediaTimestamp -> TdApi.TextEntityTypeMediaTimestamp(value.mediaTimestampSeconds)
is MessageEntityType.CustomEmoji -> TdApi.TextEntityTypeCustomEmoji(value.emojiId)
is MessageEntityType.Other -> return null
}
Expand Down Expand Up @@ -1580,11 +1588,7 @@ class TdMessageRemoteDataSource(
url: String,
theme: ThemeParams?
): WebAppInfoModel? {
val parameters = TdApi.WebAppOpenParameters().apply {
this.applicationName = "android"
this.mode = TdApi.WebAppOpenModeFullSize()
this.theme = theme?.toApi()
}
val parameters = buildDefaultWebAppOpenParameters(theme)

val isMenuUrl = url.startsWith("menu://")
val normalizedUrl = if (isMenuUrl) url.removePrefix("menu://") else url
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.monogram.data.datasource.remote

import org.drinkless.tdlib.TdApi
import org.monogram.data.mapper.toApi
import org.monogram.domain.models.webapp.ThemeParams

internal fun buildDefaultWebAppOpenParameters(theme: ThemeParams?): TdApi.WebAppOpenParameters =
TdApi.WebAppOpenParameters().apply {
applicationName = "android"
mode = TdApi.WebAppOpenModeFullSize()
this.theme = theme?.toApi()
}
2 changes: 2 additions & 0 deletions data/src/main/java/org/monogram/data/di/dataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ import org.monogram.domain.repository.ProfilePhotoRepository
import org.monogram.domain.repository.ProxyDiagnosticsRepository
import org.monogram.domain.repository.ProxyRepository
import org.monogram.domain.repository.PushDebugRepository
import org.monogram.domain.repository.RichTextParsingRepository
import org.monogram.domain.repository.SessionRepository
import org.monogram.domain.repository.SponsorRepository
import org.monogram.domain.repository.StickerRepository
Expand Down Expand Up @@ -726,6 +727,7 @@ val dataModule = module {
single<InlineBotRepository> { get<MessageRepository>() }
single<ChatEventLogRepository> { get<MessageRepository>() }
single<MessageAiRepository> { get<MessageRepository>() }
single<RichTextParsingRepository> { get<MessageRepository>() as RichTextParsingRepository }
single<PaymentRepository> { get<MessageRepository>() }
single<FileRepository> { get<MessageRepository>() }
single<WebAppRepository> { get<MessageRepository>() }
Expand Down
Loading