summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-10-22 09:19:18 -0700
committer=Corey Hulen <corey@hulen.com>2015-10-22 09:19:18 -0700
commit54894e90ac705eab3bf0f34c8dd197bb0929feae (patch)
tree2fd5c6bc1bdb8cef1ea6095e8f12f8fd73a52ce9 /api
parentc4c04e5f02253dfdfc2bd09e06955f1f5932ce18 (diff)
parent649f42e3fc706f8fa829276bcdb825381bc703f2 (diff)
downloadchat-54894e90ac705eab3bf0f34c8dd197bb0929feae.tar.gz
chat-54894e90ac705eab3bf0f34c8dd197bb0929feae.tar.bz2
chat-54894e90ac705eab3bf0f34c8dd197bb0929feae.zip
Fixing merge conflict
Diffstat (limited to 'api')
-rw-r--r--api/command.go29
-rw-r--r--api/file.go10
-rw-r--r--api/team.go9
3 files changed, 41 insertions, 7 deletions
diff --git a/api/command.go b/api/command.go
index 52ff8fffd..54f863c48 100644
--- a/api/command.go
+++ b/api/command.go
@@ -22,6 +22,7 @@ var commands = []commandHandler{
joinCommand,
loadTestCommand,
echoCommand,
+ shrugCommand,
}
var echoSem chan bool
@@ -160,6 +161,34 @@ func echoCommand(c *Context, command *model.Command) bool {
return false
}
+func shrugCommand(c *Context, command *model.Command) bool {
+ cmd := "/shrug"
+
+ if !command.Suggest && strings.Index(command.Command, cmd) == 0 {
+ message := "¯\\_(ツ)_/¯"
+
+ parameters := strings.SplitN(command.Command, " ", 2)
+ if len(parameters) > 1 {
+ message += " " + parameters[1]
+ }
+
+ post := &model.Post{}
+ post.Message = message
+ post.ChannelId = command.ChannelId
+ if _, err := CreatePost(c, post, false); err != nil {
+ l4g.Error("Unable to create /shrug post post, err=%v", err)
+ return false
+ }
+ command.Response = model.RESP_EXECUTED
+ return true
+
+ } else if strings.Index(cmd, command.Command) == 0 {
+ command.AddSuggestion(&model.SuggestCommand{Suggestion: cmd, Description: "Adds ¯\\_(ツ)_/¯ to your message, /shrug [message]"})
+ }
+
+ return false
+}
+
func joinCommand(c *Context, command *model.Command) bool {
// looks for "/join channel-name"
diff --git a/api/file.go b/api/file.go
index 142ef7ac7..94eea516a 100644
--- a/api/file.go
+++ b/api/file.go
@@ -23,6 +23,7 @@ import (
"image/jpeg"
"io"
"io/ioutil"
+ "mime"
"net/http"
"net/url"
"os"
@@ -331,9 +332,18 @@ func getFileInfo(c *Context, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "max-age=2592000, public")
+ var mimeType string
+ ext := filepath.Ext(filename)
+ if model.IsFileExtImage(ext) {
+ mimeType = model.GetImageMimeType(ext)
+ } else {
+ mimeType = mime.TypeByExtension(ext)
+ }
+
result := make(map[string]string)
result["filename"] = filename
result["size"] = size
+ result["mime"] = mimeType
w.Write([]byte(model.MapToJson(result)))
}
diff --git a/api/team.go b/api/team.go
index 666fd909b..d39d8ed60 100644
--- a/api/team.go
+++ b/api/team.go
@@ -108,7 +108,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) {
team.Name = model.CleanTeamName(team.Name)
- if err := team.IsValid(); err != nil {
+ if err := team.IsValid(*utils.Cfg.TeamSettings.RestrictTeamNames); err != nil {
c.Err = err
return
}
@@ -164,7 +164,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
teamSignup.Team.PreSave()
- if err := teamSignup.Team.IsValid(); err != nil {
+ if err := teamSignup.Team.IsValid(*utils.Cfg.TeamSettings.RestrictTeamNames); err != nil {
c.Err = err
return
}
@@ -379,11 +379,6 @@ func FindTeamByName(c *Context, name string, all string) bool {
return false
}
- if model.IsReservedTeamName(name) {
- c.Err = model.NewAppError("findTeamByName", "This URL is unavailable. Please try another.", "name="+name)
- return false
- }
-
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
return false
} else {