예제 #1
0
파일: jobs.go 프로젝트: kch42/mailremind
func jobToTpldata(job model.Job, user model.User) *jobTpldata {
	excerpt := string(job.Content())
	if len(excerpt) > 100 {
		excerpt = string([]rune(excerpt)[0:100]) + " (...)"
	}

	return &jobTpldata{
		ID:      job.ID().String(),
		Subject: job.Subject(),
		Excerpt: excerpt,
		Next:    job.Next().In(user.Location()).Format("2006-Jan-02 15:04:05"),
	}
}
예제 #2
0
파일: jobedit.go 프로젝트: kch42/mailremind
func (jt *jobeditTpldata) fillFromJob(job model.Job, u model.User) {
	jt.JobID = job.ID().String()
	jt.Subject = job.Subject()
	jt.Content = string(job.Content())
	jt.Schedules = make([]scheduleTpldata, maxSchedules)

	for i, sched := range job.Schedule() {
		if i == maxSchedules {
			log.Printf("Job %s has more than %d schedule entries!", job.ID(), maxSchedules)
			break
		}

		jt.Schedules[i] = schedToSchedTL(sched, u)
	}
}
예제 #3
0
func sendjob(job model.Job, t time.Time) bool {
	user := job.User()
	buf := new(bytes.Buffer)

	fmt.Fprintf(buf, "From: %s\n", MailFrom)
	fmt.Fprintf(buf, "To: %s\n", user.Email())
	fmt.Fprintf(buf, "Subject: %s\n", job.Subject())
	fmt.Fprintf(buf, "Date: %s\n", t.In(user.Location()).Format(time.RFC1123Z))

	fmt.Fprintln(buf, "")

	buf.Write(job.Content())

	return Mail(user.Email(), MailFrom, buf.Bytes())
}