Пример #1
0
// queueBounceMessage  bounce a message
func queueBounceMessage(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.QueueBounceMsg(msgIdInt)
	if err == gorm.RecordNotFound {
		httpWriteErrorJson(w, 404, "no such message "+msgIdStr, "")
		return
	}
	if err != nil {
		httpWriteErrorJson(w, 500, "unable to bounce message "+msgIdStr, err.Error())
		return
	}
}
Пример #2
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()
			},
		},
	},
}