Esempio n. 1
0
func AdminRejectGET(w http.ResponseWriter, r *http.Request) {
	// Get session
	sess := session.Instance(r)

	var params httprouter.Params
	params = context.Get(r, "params").(httprouter.Params)

	userid := params.ByName("userid")
	picid := params.ByName("picid")
	note := r.FormValue("note")
	uid, _ := strconv.Atoi(userid)

	err := model.PhotoReject(picid, uint64(uid), note)
	if err != nil {
		log.Println(err)
		sess.AddFlash(view.Flash{"An error occurred on the server. Please try again later.", view.FlashError})
		sess.Save(r, w)
	} else {
		sess.AddFlash(view.Flash{"Photo rejected!", view.FlashSuccess})
		sess.Save(r, w)

		user_info, err := model.UserEmailByUserId(int64(uid))
		if err != nil {
			log.Println()
		} else {
			c := view.ReadConfig()

			// Email the update to the user
			err := emailer.SendEmail(user_info.Email, "Photo Rejected on Verified.ninja",
				"Hi "+user_info.First_name+",\n\nYour photo ("+picid+") was rejected for the following reason(s):\n"+note+"\n\nPlease upload a new private photo for verification: "+c.BaseURI)
			if err != nil {
				log.Println(err)
			}
		}
	}

	// Display the view
	v := view.New(r)
	v.SendFlashes(w)
}
Esempio n. 2
0
func AdminApproveGET(w http.ResponseWriter, r *http.Request) {
	// Get session
	sess := session.Instance(r)

	var params httprouter.Params
	params = context.Get(r, "params").(httprouter.Params)
	userid := params.ByName("userid")
	picid := params.ByName("picid")
	uid, _ := strconv.Atoi(userid)

	err := model.PhotoApprove(picid, uint64(uid))
	if err != nil {
		log.Println(err)
		sess.AddFlash(view.Flash{"An error occurred on the server. Please try again later.", view.FlashError})
		sess.Save(r, w)
	} else {
		sess.AddFlash(view.Flash{"Photo approved!", view.FlashSuccess})
		sess.Save(r, w)

		user_info, err := model.UserEmailByUserId(int64(uid))
		if err != nil {
			log.Println()
		} else {
			c := view.ReadConfig()

			// Email the update to the user
			err := emailer.SendEmail(user_info.Email, "Photo Approved on Verified.ninja",
				"Hi "+user_info.First_name+",\n\nYour photo ("+picid+") was approved!\n\nLogin to see your updated profile: "+c.BaseURI)
			if err != nil {
				log.Println(err)
			}
		}
	}

	// Display the view
	v := view.New(r)
	v.SendFlashes(w)
}