mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-24575 handle auto-respond to self (#14410)
This commit is contained in:
@@ -18,6 +18,10 @@ func (a *App) SendAutoResponseIfNecessary(channel *model.Channel, sender *model.
|
||||
}
|
||||
|
||||
receiverId := channel.GetOtherUserIdForDM(sender.Id)
|
||||
if receiverId == "" {
|
||||
// User direct messaged themself, let them test their auto-responder.
|
||||
receiverId = sender.Id
|
||||
}
|
||||
|
||||
receiver, err := a.GetUser(receiverId)
|
||||
if err != nil {
|
||||
|
||||
14
app/post.go
14
app/post.go
@@ -419,12 +419,14 @@ func (a *App) handlePostEvents(post *model.Post, user *model.User, channel *mode
|
||||
return err
|
||||
}
|
||||
|
||||
a.Srv().Go(func() {
|
||||
_, err := a.SendAutoResponseIfNecessary(channel, user)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to send auto response", mlog.String("user_id", user.Id), mlog.String("post_id", post.Id), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
if post.Type != model.POST_AUTO_RESPONDER { // don't respond to an auto-responder
|
||||
a.Srv().Go(func() {
|
||||
_, err := a.SendAutoResponseIfNecessary(channel, user)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to send auto response", mlog.String("user_id", user.Id), mlog.String("post_id", post.Id), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if triggerWebhooks {
|
||||
a.Srv().Go(func() {
|
||||
|
||||
Reference in New Issue
Block a user