fix(bot): wait for database insert before deleting original message
Closes #495 Co-authored-by: spiral <spiral@spiral.sh>
This commit is contained in:
parent
3fd16182f0
commit
1c159c37ff
@ -420,8 +420,7 @@ public class ProxyService
|
|||||||
Sender = triggerMessage.Author.Id
|
Sender = triggerMessage.Author.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
Task SaveMessageInDatabase()
|
Task saveMessageInDatabase = _repo.AddMessage(sentMessage);
|
||||||
=> _repo.AddMessage(sentMessage);
|
|
||||||
|
|
||||||
async Task SaveMessageInRedis()
|
async Task SaveMessageInRedis()
|
||||||
{
|
{
|
||||||
@ -458,6 +457,10 @@ public class ProxyService
|
|||||||
|
|
||||||
// Wait a second or so before deleting the original message
|
// Wait a second or so before deleting the original message
|
||||||
await Task.Delay(MessageDeletionDelay);
|
await Task.Delay(MessageDeletionDelay);
|
||||||
|
|
||||||
|
// Wait until the message info is done saving in the database
|
||||||
|
await saveMessageInDatabase;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _rest.DeleteMessage(triggerMessage.ChannelId, triggerMessage.Id);
|
await _rest.DeleteMessage(triggerMessage.ChannelId, triggerMessage.Id);
|
||||||
@ -475,7 +478,7 @@ public class ProxyService
|
|||||||
// Run post-proxy actions (simultaneously; order doesn't matter)
|
// Run post-proxy actions (simultaneously; order doesn't matter)
|
||||||
await Task.WhenAll(
|
await Task.WhenAll(
|
||||||
DeleteProxyTriggerMessage(),
|
DeleteProxyTriggerMessage(),
|
||||||
SaveMessageInDatabase(),
|
saveMessageInDatabase,
|
||||||
SaveMessageInRedis(),
|
SaveMessageInRedis(),
|
||||||
UpdateMemberForSentMessage(),
|
UpdateMemberForSentMessage(),
|
||||||
LogMessageToChannel(),
|
LogMessageToChannel(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user