本文整理汇总了Golang中github.com/skypies/complaints/complaintdb.ComplaintDB.GetProfileByEmailAddress方法的典型用法代码示例。如果您正苦于以下问题:Golang ComplaintDB.GetProfileByEmailAddress方法的具体用法?Golang ComplaintDB.GetProfileByEmailAddress怎么用?Golang ComplaintDB.GetProfileByEmailAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skypies/complaints/complaintdb.ComplaintDB
的用法示例。
在下文中一共展示了ComplaintDB.GetProfileByEmailAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: bksvSubmitUserHandler
func bksvSubmitUserHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
cdb := complaintdb.ComplaintDB{C: c, Memcache: true}
start, end := date.WindowForYesterday()
bksv_ok, bksv_not_ok := 0, 0
email := r.FormValue("user")
if cp, err := cdb.GetProfileByEmailAddress(email); err != nil {
c.Errorf(" /bksv/submit-user(%s): getprofile: %v", email, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else if complaints, err := cdb.GetComplaintsInSpanByEmailAddress(email, start, end); err != nil {
c.Errorf(" /bksv/submit-user(%s): getcomplaints: %v", email, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
for i, complaint := range complaints {
time.Sleep(time.Millisecond * 200)
if debug, err := bksv.PostComplaint(urlfetch.Client(c), *cp, complaint); err != nil {
//cdb.C.Infof("pro: %v", cp)
//cdb.C.Infof("comp: %#v", complaint)
cdb.C.Errorf("BKSV posting error: %v", err)
cdb.C.Infof("BKSV Debug\n------\n%s\n------\n", debug)
bksv_not_ok++
} else {
if i == 0 {
cdb.C.Infof("BKSV [OK] Debug\n------\n%s\n------\n", debug)
}
bksv_ok++
}
}
}
c.Infof("bksv for %s, %d/%d", email, bksv_ok, bksv_not_ok)
if bksv_not_ok > 0 {
c.Errorf("bksv for %s, %d/%d", email, bksv_ok, bksv_not_ok)
}
w.Write([]byte("OK"))
}
示例2: profileFormHandler
func profileFormHandler(w http.ResponseWriter, r *http.Request) {
// https, yay
if r.URL.Host == "stop.jetnoise.net" {
// We're behind cloudflare, so we always see http. This is how we can tell if the user is
// using https ...
if r.Header.Get("Cf-Visitor") != `{"scheme":"https"}` {
safeUrl := r.URL
safeUrl.Scheme = "https"
http.Redirect(w, r, safeUrl.String(), http.StatusFound)
return
}
}
c := appengine.NewContext(r)
session := sessions.Get(r)
if session.Values["email"] == nil {
http.Error(w, "session was empty; no cookie ? is this browser in privacy mode ?",
http.StatusInternalServerError)
return
}
email := session.Values["email"].(string)
cdb := complaintdb.ComplaintDB{C: c}
cp, _ := cdb.GetProfileByEmailAddress(email)
if cp.EmailAddress == "" {
// First ever visit - empty profile !
cp.EmailAddress = email
cp.CcSfo = true
}
var params = map[string]interface{}{
"Profile": cp,
"MapsAPIKey": kGoogleMapsAPIKey, // For autocomplete & latlong goodness
}
params["Message"] = r.FormValue("msg")
if err := templates.ExecuteTemplate(w, "profile-edit", params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
示例3: emailHandler
func emailHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
session := sessions.Get(r)
cdb := complaintdb.ComplaintDB{C: c}
cp, err := cdb.GetProfileByEmailAddress(session.Values["email"].(string))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
start, end := date.WindowForYesterday()
// end = time.Now()
complaints, err2 := cdb.GetComplaintsInSpanByEmailAddress(cp.EmailAddress, start, end)
if err2 != nil {
http.Error(w, err2.Error(), http.StatusInternalServerError)
return
}
var cap = types.ComplaintsAndProfile{
Profile: *cp,
Complaints: complaints,
}
if err := templates.ExecuteTemplate(w, "email-update", map[string]interface{}{}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
return
}
msg, err3 := GenerateEmail(c, cap)
if err3 != nil {
http.Error(w, err3.Error(), http.StatusInternalServerError)
return
}
cap.Profile.CcSfo = true
if len(cap.Complaints) == 0 {
http.Error(w, "No complaints found ?!", http.StatusInternalServerError)
return
}
msg2, err4 := GenerateSingleComplaintEmail(c, cap.Profile, cap.Complaints[len(cap.Complaints)-1])
if err4 != nil {
http.Error(w, err4.Error(), http.StatusInternalServerError)
return
}
var params = map[string]interface{}{
"Cap": cap,
"EmailBundle": msg,
"EmailSingle": msg2,
"EmailBundleBody": template.HTML(msg.HTMLBody),
"EmailSingleBody": template.HTML(msg2.HTMLBody),
}
/* if err4 := sendViaHTTPGateway(c, msg); err4 != nil {
http.Error(w, err4.Error(), http.StatusInternalServerError)
return
} */
if err := templates.ExecuteTemplate(w, "email-debug", params); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}