Expand Plugin and REST APIs to trigger user typing event (#14331)

Этот коммит содержится в:
Attila Molnar
2020-06-16 16:41:05 +07:00
коммит произвёл GitHub
родитель 8c1164d86b
Коммит 66597d0fcb
14 изменённых файлов: 267 добавлений и 8 удалений

Просмотреть файл

@@ -774,6 +774,7 @@ type AppIface interface {
ProcessSlackText(text string) string
Publish(message *model.WebSocketEvent)
PublishSkipClusterSend(message *model.WebSocketEvent)
PublishUserTyping(userId, channelId, parentId string) *model.AppError
PurgeBleveIndexes() *model.AppError
PurgeElasticsearchIndexes() *model.AppError
ReadFile(path string) ([]byte, *model.AppError)

Просмотреть файл

@@ -10750,6 +10750,28 @@ func (a *OpenTracingAppLayer) PublishSkipClusterSend(message *model.WebSocketEve
a.app.PublishSkipClusterSend(message)
}
func (a *OpenTracingAppLayer) PublishUserTyping(userId string, channelId string, parentId string) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PublishUserTyping")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0 := a.app.PublishUserTyping(userId, channelId, parentId)
if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0))
ext.Error.Set(span, true)
}
return resultVar0
}
func (a *OpenTracingAppLayer) PurgeBleveIndexes() *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PurgeBleveIndexes")

Просмотреть файл

@@ -850,6 +850,10 @@ func (api *PluginAPI) DeleteBotIconImage(userId string) *model.AppError {
return api.app.DeleteBotIconImage(userId)
}
func (api *PluginAPI) PublishUserTyping(userId, channelId, parentId string) *model.AppError {
return api.app.PublishUserTyping(userId, channelId, parentId)
}
func (api *PluginAPI) PluginHTTP(request *http.Request) *http.Response {
split := strings.SplitN(request.URL.Path, "/", 3)
if len(split) != 3 {

Просмотреть файл

@@ -2088,6 +2088,18 @@ func (a *App) DemoteUserToGuest(user *model.User) *model.AppError {
return nil
}
func (a *App) PublishUserTyping(userId, channelId, parentId string) *model.AppError {
omitUsers := make(map[string]bool, 1)
omitUsers[userId] = true
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_TYPING, "", channelId, "", omitUsers)
event.Add("parent_id", parentId)
event.Add("user_id", userId)
a.Publish(event)
return nil
}
// invalidateUserCacheAndPublish Invalidates cache for a user and publishes user updated event
func (a *App) invalidateUserCacheAndPublish(userId string) {
a.InvalidateCacheForUser(userId)