コード例 #1
0
ファイル: app.go プロジェクト: yindeming/ForrestFire
func BounceHandler(res Response, req *http.Request) {
	decoder := json.NewDecoder(req.Body)
	var bounce postmark.Bounce
	err := decoder.Decode(&bounce)
	if err != nil {
		logger.Printf("failed decoding bounce: %s", err)
		return
	}

	if looper.AlreadyResent(bounce.MessageID, bounce.Email) {
		logger.Printf("skipping resend of message ID %s", bounce.MessageID)
	} else {
		err = app.Reactivate(bounce)
		if err != nil {
			logger.Printf("failed reactivating bounce: %s", err)
			return
		}
		uri := looper.MarkResent(bounce.MessageID, bounce.Email)
		if job, err := J.New(bounce.Email, uri, ""); err != nil {
			logger.Printf("bounced email failed to validate as a job: %s", err)
		} else {
			app.Queue(*job)
			logger.Printf("resending %#v to %#v after bounce", uri, bounce.Email)
		}
	}
	w := res.Plain()
	io.WriteString(w, "ok")
}
コード例 #2
0
ファイル: main.go プロジェクト: yindeming/ForrestFire
func main() {
	check(url, email, rdbToken, pmToken, from, kindlegen)
	app := tinderizer.New(rdbToken, pmToken, from, kindlegen, logger)
	app.Run(1)

	job, err := J.New(email, url, "")
	if err != nil {
		log.Fatalf("failed building job: %s", err)
	}

	app.Queue(*job)
	app.Shutdown()
}
コード例 #3
0
ファイル: app.go プロジェクト: yindeming/ForrestFire
func Submit(encoder *json.Encoder, email, url, content string) {
	job, err := J.New(email, url, content)
	if err != nil {
		HandleSubmitError(encoder, err)
		return
	}

	job.Progress("Working...")
	app.Queue(*job)
	encoder.Encode(JSON{
		"message": "Submitted! Hang tight...",
		"id":      job.Key.String(),
	})
}
コード例 #4
0
ファイル: app.go プロジェクト: yindeming/ForrestFire
func InboundHandler(res Response, req *http.Request) {
	decoder := json.NewDecoder(req.Body)
	var inbound InboundEmail
	err := decoder.Decode(&inbound)
	if err != nil {
		logger.Printf("failed decoding inbound email: %s", err)
	} else {
		email, url, err := ExtractParts(&inbound)
		if err != nil {
			logger.Printf("failed extracting needed parts from email: %s", err)
		} else {
			logger.Printf("email submission of %#v to %#v", url, email)
			if job, err := J.New(email, url, ""); err == nil {
				app.Queue(*job)
			}
		}
	}
	w := res.Plain()
	io.WriteString(w, "ok")
}