~kameliya/tori

c2e19c24171f299de10773ce03ffe6db2a602bd8 — Asherah Connor 1 year, 2 months ago 0669d46
improve logging somewhat
1 files changed, 12 insertions(+), 3 deletions(-)

M backend/http.go
M backend/http.go => backend/http.go +12 -3
@@ 227,6 227,8 @@ func (tori *toriState) createMuteHandler(w http.ResponseWriter, req *http.Reques
		return
	}

	tori.log.info.Printf("muting for owner @%s (row %d): @%s (Twitter ID %s)", user.TwitterScreenName, muteID, muteScreenName, muteUserID)

	w.WriteHeader(http.StatusCreated)
	jsonResponse(w, createMuteResponse{mutesResponseMute{
		ID:         muteID,


@@ 256,22 258,29 @@ func (tori *toriState) destroyMuteHandler(w http.ResponseWriter, req *http.Reque

	unmute := req.URL.Query().Get("unmute") == "true"

	var muteUserID string
	var (
		muteUserID string
		muteScreenName string
	)
	err = tori.db.QueryRow(`
		DELETE FROM mutes
		WHERE
			id = $1 AND
			owner_user_id = $2
		RETURNING user_id
	`, muteID, user.ID).Scan(&muteUserID)
		RETURNING user_id, screen_name
	`, muteID, user.ID).Scan(&muteUserID, &muteScreenName)
	if err != nil {
		w.WriteHeader(http.StatusBadRequest)
		return
	}

	muteText := "without unmuting"
	if unmute {
		user.Unmute(tori, muteUserID)
		muteText = "with unmuting"
	}

	tori.log.info.Printf("destroying mute for owner @%s (row %d) %s: @%s (Twitter ID %s)", user.TwitterScreenName, muteID, muteText, muteScreenName, muteUserID)

	jsonResponse(w, map[string]interface{}{})
}