diff --git a/app/channels.go b/app/channels.go index da69a68dce..58ec7530fa 100644 --- a/app/channels.go +++ b/app/channels.go @@ -215,6 +215,10 @@ func NewChannels(s *Server, services map[ServiceKey]interface{}) (*Channels, err pluginsRoute.HandleFunc("/public/{public_file:.*}", ch.ServePluginPublicRequest) pluginsRoute.HandleFunc("/{anything:.*}", ch.ServePluginRequest) + services[PostKey] = &postServiceWrapper{ + app: &App{ch: ch}, + } + return ch, nil } diff --git a/app/post.go b/app/post.go index 7957873194..3bdf210b53 100644 --- a/app/post.go +++ b/app/post.go @@ -32,6 +32,14 @@ const ( var atMentionPattern = regexp.MustCompile(`\B@`) +type postServiceWrapper struct { + app AppIface +} + +func (s *postServiceWrapper) CreatePost(ctx *request.Context, post *model.Post) (*model.Post, *model.AppError) { + return s.app.CreatePostMissingChannel(ctx, post, true) +} + func (a *App) CreatePostAsUser(c *request.Context, post *model.Post, currentSessionId string, setOnline bool) (*model.Post, *model.AppError) { // Check that channel has not been deleted channel, errCh := a.Srv().Store.Channel().Get(post.ChannelId, true) diff --git a/app/server.go b/app/server.go index 1e3ed63161..0a3ed916eb 100644 --- a/app/server.go +++ b/app/server.go @@ -94,6 +94,7 @@ const ( LicenseKey ServiceKey = "license" FilestoreKey ServiceKey = "filestore" ClusterKey ServiceKey = "cluster" + PostKey ServiceKey = "post" ) type Server struct {