PLT-6965 jira integration (plus plugin scaffolding) (#6918)
* plugin scaffolding / jira integration * add vendored testify packages * webhook fix * don't change i18n ids * support configuration watching * add basic jira plugin configuration to admin console * fix eslint errors * fix another eslint warning * polish * undo unintentional config.json commit >:( * test fix * add jira plugin diagnostics, remove dm support, add bot tag, generate web-safe secrets * rebase, implement requested changes * requested changes * remove tests and minimize makefile change * add missing license headers * add missing comma * remove bad line from Makefile
Этот коммит содержится в:
@@ -490,48 +490,43 @@ func HandleIncomingWebhook(hookId string, req *model.IncomingWebhookRequest) *mo
|
||||
|
||||
var channel *model.Channel
|
||||
var cchan store.StoreChannel
|
||||
var directUserId string
|
||||
|
||||
if len(channelName) != 0 {
|
||||
if channelName[0] == '@' {
|
||||
if result := <-Srv.Store.User().GetByUsername(channelName[1:]); result.Err != nil {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.user.app_error", nil, "err="+result.Err.Message, http.StatusBadRequest)
|
||||
} else {
|
||||
directUserId = result.Data.(*model.User).Id
|
||||
channelName = model.GetDMNameFromIds(directUserId, hook.UserId)
|
||||
if ch, err := GetDirectChannel(hook.UserId, result.Data.(*model.User).Id); err != nil {
|
||||
return err
|
||||
} else {
|
||||
channel = ch
|
||||
}
|
||||
}
|
||||
} else if channelName[0] == '#' {
|
||||
channelName = channelName[1:]
|
||||
cchan = Srv.Store.Channel().GetByName(hook.TeamId, channelName[1:], true)
|
||||
} else {
|
||||
cchan = Srv.Store.Channel().GetByName(hook.TeamId, channelName, true)
|
||||
}
|
||||
|
||||
cchan = Srv.Store.Channel().GetByName(hook.TeamId, channelName, true)
|
||||
} else {
|
||||
cchan = Srv.Store.Channel().Get(hook.ChannelId, true)
|
||||
}
|
||||
|
||||
overrideUsername := req.Username
|
||||
overrideIconUrl := req.IconURL
|
||||
|
||||
result := <-cchan
|
||||
if result.Err != nil && result.Err.Id == store.MISSING_CHANNEL_ERROR && directUserId != "" {
|
||||
newChanResult := <-Srv.Store.Channel().CreateDirectChannel(directUserId, hook.UserId)
|
||||
if newChanResult.Err != nil {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.channel.app_error", nil, "err="+newChanResult.Err.Message, http.StatusBadRequest)
|
||||
if channel == nil {
|
||||
result := <-cchan
|
||||
if result.Err != nil {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.channel.app_error", nil, "err="+result.Err.Message, result.Err.StatusCode)
|
||||
} else {
|
||||
channel = newChanResult.Data.(*model.Channel)
|
||||
InvalidateCacheForUser(directUserId)
|
||||
InvalidateCacheForUser(hook.UserId)
|
||||
channel = result.Data.(*model.Channel)
|
||||
}
|
||||
} else if result.Err != nil {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.channel.app_error", nil, "err="+result.Err.Message, result.Err.StatusCode)
|
||||
} else {
|
||||
channel = result.Data.(*model.Channel)
|
||||
}
|
||||
|
||||
if channel.Type != model.CHANNEL_OPEN && !HasPermissionToChannel(hook.UserId, channel.Id, model.PERMISSION_READ_CHANNEL) {
|
||||
return model.NewAppError("HandleIncomingWebhook", "web.incoming_webhook.permissions.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
overrideUsername := req.Username
|
||||
overrideIconUrl := req.IconURL
|
||||
|
||||
if _, err := CreateWebhookPost(hook.UserId, hook.TeamId, channel.Id, text, overrideUsername, overrideIconUrl, req.Props, webhookType); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user