Skip to content

Commit

Permalink
increase messages limit
Browse files Browse the repository at this point in the history
  • Loading branch information
atanana committed Nov 20, 2017
1 parent db32617 commit 44b96b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/scala/com/atanana/vk_digest/vk/MessageProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ class MessageProvider @Inject()(
private val vkApiClient: VkApiClient,
private val config: VkConfig
) {
private val messagesCount = 200

def messages(lastMessageId: Option[Int]): List[Message] = {
vkApiClient.messages()
.getHistory(actor)
.peerId(config.chatId)
.userId(config.userId)
.startMessageId(startMessageId(lastMessageId))
.offset(offset(lastMessageId))
.count(50)
.count(messagesCount)
.execute()
.getItems
.asScala.toList
}

private def offset(lastMessageId: Option[Int]): Int = {
lastMessageId.map(_ => -50).getOrElse(0)
lastMessageId.map(_ => -messagesCount).getOrElse(0)
}

private def startMessageId(lastMessageId: Option[Int]): Int = {
Expand Down

0 comments on commit 44b96b8

Please sign in to comment.