Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
c63e1da7
Commit
c63e1da7
authored
Jul 03, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial message db models and DAO, save messages to database
parent
cb57e76e
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
537 additions
and
88 deletions
+537
-88
ChatRoomFragmentModule.kt
...chat/rocket/android/chatroom/di/ChatRoomFragmentModule.kt
+23
-0
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+3
-0
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+3
-4
ChatRoomDao.kt
app/src/main/java/chat/rocket/android/db/ChatRoomDao.kt
+1
-1
DatabaseManager.kt
app/src/main/java/chat/rocket/android/db/DatabaseManager.kt
+151
-62
DatabaseMessagesRepository.kt
...java/chat/rocket/android/db/DatabaseMessagesRepository.kt
+18
-0
MessageDao.kt
app/src/main/java/chat/rocket/android/db/MessageDao.kt
+86
-0
RCDatabase.kt
app/src/main/java/chat/rocket/android/db/RCDatabase.kt
+18
-16
Attachments.kt
...src/main/java/chat/rocket/android/db/model/Attachments.kt
+70
-0
Messages.kt
app/src/main/java/chat/rocket/android/db/model/Messages.kt
+67
-0
Reactions.kt
app/src/main/java/chat/rocket/android/db/model/Reactions.kt
+31
-0
Url.kt
app/src/main/java/chat/rocket/android/db/model/Url.kt
+26
-0
MessagesRepository.kt
.../chat/rocket/android/infrastructure/MessagesRepository.kt
+8
-0
ConnectionManager.kt
...ocket/android/server/infraestructure/ConnectionManager.kt
+9
-5
RocketChatClient.kt
...a/chat/rocket/android/util/extensions/RocketChatClient.kt
+23
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/di/ChatRoomFragmentModule.kt
View file @
c63e1da7
...
...
@@ -5,9 +5,14 @@ import chat.rocket.android.chatroom.presentation.ChatRoomView
import
chat.rocket.android.chatroom.ui.ChatRoomFragment
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.db.ChatRoomDao
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManagerFactory
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
dagger.Module
import
dagger.Provides
import
kotlinx.coroutines.experimental.Job
import
javax.inject.Named
@Module
class
ChatRoomFragmentModule
{
...
...
@@ -33,4 +38,22 @@ class ChatRoomFragmentModule {
fun
provideCancelStrategy
(
owner
:
LifecycleOwner
,
jobs
:
Job
):
CancelStrategy
{
return
CancelStrategy
(
owner
,
jobs
)
}
@Provides
@PerFragment
@Named
(
"currentServer"
)
fun
provideCurrentServer
(
currentServerInteractor
:
GetCurrentServerInteractor
):
String
{
return
currentServerInteractor
.
get
()
!!
}
@Provides
@PerFragment
fun
provideDatabaseManager
(
factory
:
DatabaseManagerFactory
,
@Named
(
"currentServer"
)
currentServer
:
String
):
DatabaseManager
{
return
factory
.
create
(
currentServer
)
}
@Provides
@PerFragment
fun
provideChatRoomDao
(
manager
:
DatabaseManager
):
ChatRoomDao
=
manager
.
chatRoomDao
()
}
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
c63e1da7
...
...
@@ -227,6 +227,7 @@ class ChatRoomPresenter @Inject constructor(
retryIO
(
"loadAndShowMessages($chatRoomId, $chatRoomType, $offset"
)
{
client
.
messages
(
chatRoomId
,
roomTypeOf
(
chatRoomType
),
offset
,
30
).
result
}
dbManager
.
processMessagesBatch
(
messages
)
messagesRepository
.
saveAll
(
messages
)
//we are saving last sync date of latest synced chat room message
...
...
@@ -510,6 +511,8 @@ class ChatRoomPresenter @Inject constructor(
}
Timber
.
d
(
"History: $messages"
)
dbManager
.
processMessagesBatch
(
messages
.
result
)
if
(
messages
.
result
.
isNotEmpty
())
{
val
models
=
mapper
.
map
(
messages
.
result
,
RoomUiModel
(
roles
=
chatRoles
,
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
c63e1da7
...
...
@@ -30,7 +30,6 @@ import chat.rocket.android.chatrooms.viewmodel.ChatRoomsViewModel
import
chat.rocket.android.chatrooms.viewmodel.ChatRoomsViewModelFactory
import
chat.rocket.android.chatrooms.viewmodel.LoadingState
import
chat.rocket.android.chatrooms.viewmodel.Query
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.helper.ChatRoomsSortOrder
import
chat.rocket.android.helper.Constants
import
chat.rocket.android.helper.SharedPreferenceHelper
...
...
@@ -57,10 +56,10 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
@Inject
lateinit
var
factory
:
ChatRoomsViewModelFactory
@Inject
lateinit
var
dbManager
:
DatabaseManager
// TODO - remove when moving ChatRoom screen to DB
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
lateinit
var
viewModel
:
ChatRoomsViewModel
private
lateinit
var
viewModel
:
ChatRoomsViewModel
private
var
searchView
:
SearchView
?
=
null
private
var
sortView
:
MenuItem
?
=
null
private
val
handler
=
Handler
()
...
...
app/src/main/java/chat/rocket/android/db/ChatRoomDao.kt
View file @
c63e1da7
...
...
@@ -99,7 +99,7 @@ abstract class ChatRoomDao : BaseDao<ChatRoomEntity> {
abstract
fun
update
(
list
:
List
<
ChatRoomEntity
>)
@Transaction
open
fun
update
(
to
Remove
:
List
<
String
>,
toInsert
:
List
<
ChatRoomEntity
>,
toUpdate
:
List
<
ChatRoomEntity
>)
{
open
fun
update
(
to
Insert
:
List
<
ChatRoomEntity
>,
toUpdate
:
List
<
ChatRoomEntity
>,
toRemove
:
List
<
String
>)
{
insertOrReplace
(
toInsert
)
update
(
toUpdate
)
toRemove
.
forEach
{
id
->
...
...
app/src/main/java/chat/rocket/android/db/DatabaseManager.kt
View file @
c63e1da7
This diff is collapsed.
Click to expand it.
app/src/main/java/chat/rocket/android/db/DatabaseMessagesRepository.kt
0 → 100644
View file @
c63e1da7
package
chat.rocket.android.db
import
chat.rocket.android.infrastructure.MessagesRepository
import
chat.rocket.core.model.Message
class
DatabaseMessagesRepository
(
val
dbManager
:
DatabaseManager
)
:
MessagesRepository
{
override
fun
saveMessage
(
message
:
Message
)
{
saveMessages
(
listOf
(
message
))
}
override
fun
saveMessages
(
messages
:
List
<
Message
>)
{
messages
.
forEach
{
message
->
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/db/MessageDao.kt
0 → 100644
View file @
c63e1da7
package
chat.rocket.android.db
import
androidx.room.Dao
import
androidx.room.Insert
import
androidx.room.OnConflictStrategy
import
androidx.room.Query
import
androidx.room.Transaction
import
chat.rocket.android.db.model.AttachmentEntity
import
chat.rocket.android.db.model.AttachmentFieldEntity
import
chat.rocket.android.db.model.BaseMessageEntity
import
chat.rocket.android.db.model.MessageChannelsRelation
import
chat.rocket.android.db.model.MessageEntity
import
chat.rocket.android.db.model.MessageFavoritesRelation
import
chat.rocket.android.db.model.MessageMentionsRelation
import
chat.rocket.android.db.model.ReactionEntity
import
chat.rocket.android.db.model.ReactionMessageRelation
import
chat.rocket.android.db.model.UrlEntity
import
timber.log.Timber
@Dao
abstract
class
MessageDao
{
@Insert
abstract
fun
insert
(
message
:
MessageEntity
)
@Insert
abstract
fun
insert
(
relation
:
MessageFavoritesRelation
)
@Insert
abstract
fun
insert
(
relation
:
MessageMentionsRelation
)
@Insert
abstract
fun
insert
(
relation
:
MessageChannelsRelation
)
@Insert
abstract
fun
insert
(
attachment
:
AttachmentEntity
)
@Insert
abstract
fun
insert
(
field
:
AttachmentFieldEntity
)
@Insert
(
onConflict
=
OnConflictStrategy
.
IGNORE
)
abstract
fun
insert
(
reaction
:
ReactionEntity
)
@Insert
abstract
fun
insert
(
relation
:
ReactionMessageRelation
)
@Insert
abstract
fun
insert
(
url
:
UrlEntity
)
@Query
(
"DELETE FROM messages WHERE id = :id"
)
abstract
fun
delete
(
id
:
String
)
@Transaction
open
fun
insert
(
message
:
MessageEntity
,
entities
:
List
<
BaseMessageEntity
>)
{
insertInternal
(
message
,
entities
)
}
private
fun
insertInternal
(
message
:
MessageEntity
,
entities
:
List
<
BaseMessageEntity
>)
{
Timber
.
d
(
"Inserting message: ${message.id}, entities: ${entities.size}"
)
delete
(
message
.
id
)
insert
(
message
)
entities
.
forEach
{
entity
->
insert
(
entity
)
}
}
private
fun
insert
(
entity
:
BaseMessageEntity
)
{
when
(
entity
)
{
is
MessageEntity
->
insert
(
entity
)
is
MessageFavoritesRelation
->
insert
(
entity
)
is
MessageMentionsRelation
->
insert
(
entity
)
is
MessageChannelsRelation
->
insert
(
entity
)
is
AttachmentEntity
->
insert
(
entity
)
is
AttachmentFieldEntity
->
insert
(
entity
)
is
ReactionEntity
->
insert
(
entity
)
is
ReactionMessageRelation
->
insert
(
entity
)
is
UrlEntity
->
insert
(
entity
)
}
}
@Transaction
open
fun
insert
(
list
:
List
<
Pair
<
MessageEntity
,
List
<
BaseMessageEntity
>>>)
{
list
.
forEach
{
(
message
,
entities
)
->
insertInternal
(
message
,
entities
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/db/RCDatabase.kt
View file @
c63e1da7
...
...
@@ -2,29 +2,31 @@ package chat.rocket.android.db
import
androidx.room.Database
import
androidx.room.RoomDatabase
import
androidx.room.migration.Migration
import
androidx.sqlite.db.SupportSQLiteDatabase
import
chat.rocket.android.db.model.AttachmentEntity
import
chat.rocket.android.db.model.AttachmentFieldEntity
import
chat.rocket.android.db.model.ChatRoomEntity
import
chat.rocket.android.db.model.MessageChannelsRelation
import
chat.rocket.android.db.model.MessageEntity
import
chat.rocket.android.db.model.MessageFavoritesRelation
import
chat.rocket.android.db.model.MessageMentionsRelation
import
chat.rocket.android.db.model.ReactionEntity
import
chat.rocket.android.db.model.ReactionMessageRelation
import
chat.rocket.android.db.model.UrlEntity
import
chat.rocket.android.db.model.UserEntity
@Database
(
entities
=
[
UserEntity
::
class
,
ChatRoomEntity
::
class
],
version
=
5
,
entities
=
[
UserEntity
::
class
,
ChatRoomEntity
::
class
,
MessageEntity
::
class
,
MessageFavoritesRelation
::
class
,
MessageMentionsRelation
::
class
,
MessageChannelsRelation
::
class
,
AttachmentEntity
::
class
,
AttachmentFieldEntity
::
class
,
UrlEntity
::
class
,
ReactionEntity
::
class
,
ReactionMessageRelation
::
class
],
version
=
6
,
exportSchema
=
true
)
abstract
class
RCDatabase
:
RoomDatabase
()
{
abstract
fun
userDao
():
UserDao
abstract
fun
chatRoomDao
():
ChatRoomDao
companion
object
{
@JvmField
val
MIGRATION_4_5
=
Migration4to5
()
}
}
class
Migration4to5
:
Migration
(
4
,
5
)
{
override
fun
migrate
(
database
:
SupportSQLiteDatabase
)
{
database
.
execSQL
(
"CREATE INDEX `index_chatrooms_lastMessageUserId` ON `chatrooms` (`lastMessageUserId`)"
)
}
abstract
fun
messageDao
():
MessageDao
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/db/model/Attachments.kt
0 → 100644
View file @
c63e1da7
package
chat.rocket.android.db.model
import
androidx.room.ColumnInfo
import
androidx.room.Entity
import
androidx.room.ForeignKey
import
androidx.room.PrimaryKey
@Entity
(
tableName
=
"attachments"
,
foreignKeys
=
[
ForeignKey
(
entity
=
MessageEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"message_id"
],
onDelete
=
ForeignKey
.
CASCADE
)
])
data class
AttachmentEntity
(
@PrimaryKey
val
id
:
String
,
@ColumnInfo
(
name
=
"message_id"
)
val
messageId
:
String
,
val
title
:
String
?,
val
type
:
String
?,
val
description
:
String
?,
val
text
:
String
?,
@ColumnInfo
(
name
=
"author_name"
)
val
authorName
:
String
?,
@ColumnInfo
(
name
=
"author_icon"
)
val
authorIcon
:
String
?,
@ColumnInfo
(
name
=
"author_link"
)
val
authorLink
:
String
?,
@ColumnInfo
(
name
=
"thumb_url"
)
val
thumbUrl
:
String
?,
val
color
:
String
?,
@ColumnInfo
(
name
=
"title_link"
)
val
titleLink
:
String
?,
@ColumnInfo
(
name
=
"title_link_download"
)
val
titleLinkDownload
:
String
?,
@ColumnInfo
(
name
=
"image_url"
)
val
imageUrl
:
String
?,
@ColumnInfo
(
name
=
"image_type"
)
val
imageType
:
String
?,
@ColumnInfo
(
name
=
"image_size"
)
val
imageSize
:
String
?,
@ColumnInfo
(
name
=
"video_url"
)
val
videoUrl
:
String
?,
@ColumnInfo
(
name
=
"video_type"
)
val
videoType
:
String
?,
@ColumnInfo
(
name
=
"video_size"
)
val
videoSize
:
String
?,
@ColumnInfo
(
name
=
"audio_url"
)
val
audioUrl
:
String
?,
@ColumnInfo
(
name
=
"audio_type"
)
val
audioType
:
String
?,
@ColumnInfo
(
name
=
"audio_size"
)
val
audioSize
:
String
?,
@ColumnInfo
(
name
=
"message_link"
)
val
messageLink
:
String
?,
val
timestamp
:
Long
?
)
:
BaseMessageEntity
@Entity
(
tableName
=
"attachment_fields"
,
foreignKeys
=
[
ForeignKey
(
entity
=
AttachmentEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"attachmentId"
],
onDelete
=
ForeignKey
.
CASCADE
)
])
data class
AttachmentFieldEntity
(
val
attachmentId
:
String
,
val
title
:
String
,
val
value
:
String
)
:
BaseMessageEntity
{
@PrimaryKey
(
autoGenerate
=
true
)
var
id
:
Long
?
=
null
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/db/model/Messages.kt
0 → 100644
View file @
c63e1da7
package
chat.rocket.android.db.model
import
androidx.room.Entity
import
androidx.room.ForeignKey
import
androidx.room.PrimaryKey
interface
BaseMessageEntity
@Entity
(
tableName
=
"messages"
,
foreignKeys
=
[
ForeignKey
(
entity
=
UserEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"senderId"
]),
ForeignKey
(
entity
=
UserEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"editedBy"
])
])
data class
MessageEntity
(
@PrimaryKey
val
id
:
String
,
val
roomId
:
String
,
val
message
:
String
,
val
timestamp
:
Long
,
val
senderId
:
String
?,
val
updatedAt
:
Long
?,
val
editedAt
:
Long
?,
val
editedBy
:
String
?,
val
senderAlias
:
String
?,
val
avatar
:
String
?,
val
type
:
String
?,
val
groupable
:
Boolean
=
false
,
val
parseUrls
:
Boolean
=
false
,
val
pinned
:
Boolean
=
false
,
val
role
:
String
?
)
:
BaseMessageEntity
@Entity
(
tableName
=
"message_favorites"
,
primaryKeys
=
[
"messageId"
,
"userId"
],
foreignKeys
=
[
ForeignKey
(
entity
=
MessageEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"messageId"
],
onDelete
=
ForeignKey
.
CASCADE
),
ForeignKey
(
entity
=
UserEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"userId"
])
])
data class
MessageFavoritesRelation
(
val
messageId
:
String
,
val
userId
:
String
)
:
BaseMessageEntity
@Entity
(
tableName
=
"message_mentions"
,
primaryKeys
=
[
"messageId"
,
"userId"
],
foreignKeys
=
[
ForeignKey
(
entity
=
MessageEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"messageId"
],
onDelete
=
ForeignKey
.
CASCADE
),
ForeignKey
(
entity
=
UserEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"userId"
])
])
data class
MessageMentionsRelation
(
val
messageId
:
String
,
val
userId
:
String
)
:
BaseMessageEntity
@Entity
(
tableName
=
"message_channels"
,
primaryKeys
=
[
"messageId"
,
"roomId"
],
foreignKeys
=
[
ForeignKey
(
entity
=
MessageEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"messageId"
],
onDelete
=
ForeignKey
.
CASCADE
)
]
)
data class
MessageChannelsRelation
(
val
messageId
:
String
,
val
roomId
:
String
,
val
roomName
:
String
?
)
:
BaseMessageEntity
app/src/main/java/chat/rocket/android/db/model/Reactions.kt
0 → 100644
View file @
c63e1da7
package
chat.rocket.android.db.model
import
androidx.room.Entity
import
androidx.room.ForeignKey
import
androidx.room.Index
import
androidx.room.PrimaryKey
@Entity
(
tableName
=
"reactions"
)
data class
ReactionEntity
(
@PrimaryKey
val
reaction
:
String
)
:
BaseMessageEntity
@Entity
(
tableName
=
"reactions_message_relations"
,
foreignKeys
=
[
ForeignKey
(
entity
=
ReactionEntity
::
class
,
parentColumns
=
[
"reaction"
],
childColumns
=
[
"reactionId"
]),
ForeignKey
(
entity
=
MessageEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"messageId"
],
onDelete
=
ForeignKey
.
CASCADE
)
],
indices
=
[
Index
(
value
=
[
"messageId"
])
]
)
data class
ReactionMessageRelation
(
val
reactionId
:
String
,
val
messageId
:
String
,
val
count
:
Int
)
:
BaseMessageEntity
{
@PrimaryKey
(
autoGenerate
=
true
)
var
id
:
Long
?
=
null
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/db/model/Url.kt
0 → 100644
View file @
c63e1da7
package
chat.rocket.android.db.model
import
androidx.room.Entity
import
androidx.room.ForeignKey
import
androidx.room.Index
import
androidx.room.PrimaryKey
@Entity
(
tableName
=
"urls"
,
foreignKeys
=
[
ForeignKey
(
entity
=
MessageEntity
::
class
,
parentColumns
=
[
"id"
],
childColumns
=
[
"messageId"
],
onDelete
=
ForeignKey
.
CASCADE
)
],
indices
=
[
Index
(
value
=
[
"messageId"
])
])
data class
UrlEntity
(
val
messageId
:
String
,
val
url
:
String
,
val
hostname
:
String
?,
val
title
:
String
?,
val
description
:
String
?,
val
imageUrl
:
String
?
)
:
BaseMessageEntity
{
@PrimaryKey
(
autoGenerate
=
true
)
var
id
:
Long
?
=
null
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/infrastructure/MessagesRepository.kt
0 → 100644
View file @
c63e1da7
package
chat.rocket.android.infrastructure
import
chat.rocket.core.model.Message
interface
MessagesRepository
{
fun
saveMessage
(
message
:
Message
)
fun
saveMessages
(
messages
:
List
<
Message
>)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/infraestructure/ConnectionManager.kt
View file @
c63e1da7
...
...
@@ -32,7 +32,6 @@ import kotlinx.coroutines.experimental.selects.select
import
timber.log.Timber
import
java.util.concurrent.CopyOnWriteArrayList
import
kotlin.coroutines.experimental.CoroutineContext
import
kotlin.math.absoluteValue
class
ConnectionManager
(
internal
val
client
:
RocketChatClient
,
...
...
@@ -55,6 +54,7 @@ class ConnectionManager(
private
val
activeUsersContext
=
newSingleThreadContext
(
"activeUsersContext"
)
private
val
roomsContext
=
newSingleThreadContext
(
"roomsContext"
)
private
val
messagesContext
=
newSingleThreadContext
(
"messagesContext"
)
fun
connect
()
{
if
(
connectJob
?.
isActive
==
true
&&
(
state
!
is
State
.
Disconnected
))
{
...
...
@@ -125,7 +125,13 @@ class ConnectionManager(
val
roomsActor
=
createBatchActor
<
StreamMessage
<
BaseRoom
>>(
roomsContext
,
parent
=
connectJob
,
maxSize
=
10
)
{
batch
->
Timber
.
d
(
"processing Stream batch: ${batch.size} - $batch"
)
dbManager
.
processStreamBatch
(
batch
)
dbManager
.
processChatRoomsBatch
(
batch
)
}
val
messagesActor
=
createBatchActor
<
Message
>(
messagesContext
,
parent
=
connectJob
,
maxSize
=
100
,
maxTime
=
300
)
{
messages
->
Timber
.
d
(
"Processing Messages batch: ${messages.size}"
)
dbManager
.
processMessagesBatch
(
messages
)
}
// stream-notify-user - ${userId}/rooms-changed
...
...
@@ -148,6 +154,7 @@ class ConnectionManager(
launch
(
parent
=
connectJob
)
{
for
(
message
in
client
.
messagesChannel
)
{
Timber
.
d
(
"Received new Message for room ${message.roomId}"
)
messagesActor
.
send
(
message
)
val
channel
=
roomMessagesChannels
[
message
.
roomId
]
channel
?.
send
(
message
)
}
...
...
@@ -164,12 +171,9 @@ class ConnectionManager(
}
}
var
totalUsers
=
0
// activeUsers
launch
(
parent
=
connectJob
)
{
for
(
user
in
client
.
activeUsersChannel
)
{
totalUsers
++
//Timber.d("Got activeUsers: $totalUsers")
userActor
.
send
(
user
)
}
}
...
...
app/src/main/java/chat/rocket/android/util/extensions/RocketChatClient.kt
View file @
c63e1da7
package
chat.rocket.android.util.extensions
import
chat.rocket.android.db.model.MessageEntity
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.retryIO
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.registerPushToken
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.asString
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.withContext
...
...
@@ -26,4 +29,24 @@ suspend fun RocketChatClientFactory.registerPushToken(
}
}
}
}
fun
Message
.
toEntity
():
MessageEntity
{
return
MessageEntity
(
id
=
id
,
roomId
=
roomId
,
message
=
message
,
timestamp
=
timestamp
,
senderId
=
sender
?.
id
,
updatedAt
=
updatedAt
,
editedAt
=
editedAt
,
editedBy
=
editedBy
?.
id
,
senderAlias
=
senderAlias
,
avatar
=
avatar
,
type
=
type
.
asString
(),
groupable
=
groupable
,
parseUrls
=
parseUrls
,
pinned
=
pinned
,
role
=
role
)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment