server: implements /markConversation
This commit is contained in:
@@ -229,6 +229,29 @@ func (m *MockHTTPServer) handlePollUpdates(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockHTTPServer) handleMarkConversation(w http.ResponseWriter, r *http.Request) {
|
||||
guid := r.URL.Query().Get("guid")
|
||||
if len(guid) == 0 {
|
||||
log.Error().Msg("handleMarkConversation: Got empty guid parameter")
|
||||
http.Error(w, "no guid parameter specified", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// Find conversation
|
||||
convo, err := m.Server.ConversationForGUID(guid)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("handleMarkConversation: Error finding conversation (%s)", guid)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// Mark conversation
|
||||
m.Server.MarkConversationAsRead(convo)
|
||||
|
||||
// Respond 200
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func (m *MockHTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
m.logRequest(r, r.URL.Query().Encode())
|
||||
m.mux.ServeHTTP(w, r)
|
||||
@@ -248,6 +271,7 @@ func NewMockHTTPServer(config MockHTTPServerConfiguration) *MockHTTPServer {
|
||||
this.mux.Handle("/messages", http.HandlerFunc(this.handleMessages))
|
||||
this.mux.Handle("/pollUpdates", http.HandlerFunc(this.handlePollUpdates))
|
||||
this.mux.Handle("/sendMessage", http.HandlerFunc(this.handleSendMessage))
|
||||
this.mux.Handle("/markConversation", http.HandlerFunc(this.handleMarkConversation))
|
||||
|
||||
this.mux.Handle("/", http.HandlerFunc(this.handleNotFound))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user