expose emoji_enabled flag in /config response #378
This commit is contained in:
@@ -307,7 +307,7 @@ func (s *ServerCommand) newServerApp() (*serverApp, error) {
|
||||
}
|
||||
|
||||
imgProxy := &proxy.Image{Enabled: s.ImageProxy, RoutePath: "/api/v1/img", RemarkURL: s.RemarkURL}
|
||||
emojiFmt := store.CommentConverterFunc(func(text string) string { return text })
|
||||
emojiFmt := store.CommentConverterFunc(func(text string) string { return text })
|
||||
if s.EnableEmoji {
|
||||
emojiFmt = func(text string) string { return emoji.Sprint(text) }
|
||||
}
|
||||
@@ -339,6 +339,7 @@ func (s *ServerCommand) newServerApp() (*serverApp, error) {
|
||||
Refresh: s.Stream.RefreshInterval,
|
||||
MaxActive: int32(s.Stream.MaxActive),
|
||||
},
|
||||
EmojiEnabled: s.EnableEmoji,
|
||||
}
|
||||
|
||||
srv.ScoreThresholds.Low, srv.ScoreThresholds.Critical = s.LowScore, s.CriticalScore
|
||||
|
||||
@@ -55,6 +55,7 @@ type Rest struct {
|
||||
Critical int
|
||||
}
|
||||
UpdateLimiter float64
|
||||
EmojiEnabled bool
|
||||
|
||||
SSLConfig SSLConfig
|
||||
httpsServer *http.Server
|
||||
@@ -392,6 +393,7 @@ func (s *Rest) configCtrl(w http.ResponseWriter, r *http.Request) {
|
||||
PositiveScore bool `json:"positive_score"`
|
||||
ReadOnlyAge int `json:"readonly_age"`
|
||||
MaxImageSize int `json:"max_image_size"`
|
||||
EmojiEnabled bool `json:"emoji_enabled"`
|
||||
}{
|
||||
Version: s.Version,
|
||||
EditDuration: int(s.DataService.EditDuration.Seconds()),
|
||||
@@ -403,6 +405,7 @@ func (s *Rest) configCtrl(w http.ResponseWriter, r *http.Request) {
|
||||
PositiveScore: s.DataService.PositiveScore,
|
||||
ReadOnlyAge: s.ReadOnlyAge,
|
||||
MaxImageSize: s.ImageService.Store.SizeLimit(),
|
||||
EmojiEnabled: s.EmojiEnabled,
|
||||
}
|
||||
|
||||
cnf.Auth = []string{}
|
||||
|
||||
@@ -505,6 +505,7 @@ func TestRest_Config(t *testing.T) {
|
||||
assert.False(t, j["positive_score"].(bool))
|
||||
assert.Equal(t, 10., j["readonly_age"])
|
||||
assert.Equal(t, 10000., j["max_image_size"])
|
||||
assert.Equal(t, true, j["emoji_enabled"].(bool))
|
||||
t.Logf("%+v", j)
|
||||
}
|
||||
|
||||
|
||||
@@ -344,6 +344,7 @@ func startupT(t *testing.T) (ts *httptest.Server, srv *Rest, teardown func()) {
|
||||
TimeOut: 5 * time.Second,
|
||||
MaxActive: 100,
|
||||
},
|
||||
EmojiEnabled: true,
|
||||
}
|
||||
srv.ScoreThresholds.Low, srv.ScoreThresholds.Critical = -5, -10
|
||||
|
||||
|
||||
Reference in New Issue
Block a user