コード例 #1
0
ファイル: handlers_queue.go プロジェクト: teefax/tmail
// queueDiscardMessage  discard a message (delete without bouncing)
func queueDiscardMessage(w http.ResponseWriter, r *http.Request) {
	if !authorized(w, r) {
		return
	}
	msgIdStr := httpcontext.Get(r, "params").(httprouter.Params).ByName("id")
	msgIdInt, err := strconv.ParseInt(msgIdStr, 10, 64)
	if err != nil {
		httpWriteErrorJson(w, 500, "unable to get message id", err.Error())
		return
	}
	err = api.QueueDiscardMsg(msgIdInt)
	if err == gorm.RecordNotFound {
		httpWriteErrorJson(w, 404, "no such message "+msgIdStr, "")
		return
	}
	if err != nil {
		httpWriteErrorJson(w, 500, "unable to discard message "+msgIdStr, err.Error())
		return
	}
}
コード例 #2
0
ファイル: queue.go プロジェクト: teefax/tmail
				cliHandleErr(err)
				println(count)
				os.Exit(0)
			},
		},
		{
			Name:        "discard",
			Usage:       "Discard (delete without bouncing) a message in queue",
			Description: "tmail queue discard MESSAGE_ID",
			Action: func(c *cgCli.Context) {
				if len(c.Args()) != 1 {
					cliDieBadArgs(c)
				}
				id, err := strconv.ParseInt(c.Args()[0], 10, 64)
				cliHandleErr(err)
				cliHandleErr(api.QueueDiscardMsg(id))
				cliDieOk()
			},
		},
		{
			Name:        "bounce",
			Usage:       "Bounce a message in queue",
			Description: "tmail queue bounce MESSAGE_ID",
			Action: func(c *cgCli.Context) {
				if len(c.Args()) != 1 {
					cliDieBadArgs(c)
				}
				id, err := strconv.ParseInt(c.Args()[0], 10, 64)
				cliHandleErr(err)
				cliHandleErr(api.QueueBounceMsg(id))
				cliDieOk()