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
480d5032
Commit
480d5032
authored
Apr 12, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove possible messages stuck with duplicate id for any reason from the resend job queue
parent
df21f5a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
MessageService.kt
...va/chat/rocket/android/chatroom/service/MessageService.kt
+21
-19
No files found.
app/src/main/java/chat/rocket/android/chatroom/service/MessageService.kt
View file @
480d5032
...
...
@@ -35,36 +35,38 @@ class MessageService : JobService() {
launch
(
CommonPool
)
{
val
currentServer
=
currentServerRepository
.
get
()
if
(
currentServer
!=
null
)
{
params
?.
let
{
try
{
retrySendingMessages
(
currentServer
)
jobFinished
(
params
,
false
)
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
jobFinished
(
params
,
true
)
}
}
retrySendingMessages
(
params
,
currentServer
)
jobFinished
(
params
,
false
)
}
}
return
true
}
private
suspend
fun
retrySendingMessages
(
currentServer
:
String
)
{
private
suspend
fun
retrySendingMessages
(
params
:
JobParameters
?,
currentServer
:
String
)
{
val
temporaryMessages
=
messageRepository
.
getAllUnsent
()
.
sortedWith
(
compareBy
(
Message
::
timestamp
))
if
(
temporaryMessages
.
isNotEmpty
())
{
val
connectionManager
=
factory
.
create
(
currentServer
)
val
client
=
connectionManager
.
client
temporaryMessages
.
forEach
{
message
->
client
.
sendMessage
(
message
=
message
.
message
,
messageId
=
message
.
id
,
roomId
=
message
.
roomId
,
avatar
=
message
.
avatar
,
attachments
=
message
.
attachments
,
alias
=
message
.
senderAlias
)
messageRepository
.
save
(
message
.
copy
(
isTemporary
=
false
))
try
{
client
.
sendMessage
(
message
=
message
.
message
,
messageId
=
message
.
id
,
roomId
=
message
.
roomId
,
avatar
=
message
.
avatar
,
attachments
=
message
.
attachments
,
alias
=
message
.
senderAlias
)
messageRepository
.
save
(
message
.
copy
(
isTemporary
=
false
))
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
if
(
ex
.
message
?.
contains
(
"E11000"
,
true
)
==
true
)
{
// XXX: Temporary solution. We need proper error codes from the api.
messageRepository
.
save
(
message
.
copy
(
isTemporary
=
false
))
}
jobFinished
(
params
,
true
)
}
}
}
}
...
...
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