Example #1
0
func initRoutes() {
	user := user.User{}
	user.InitUser()

	session := session.Session{}
	session.InitSession()

	place := place.Place{}
	place.InitPlace()

	post := post.Post{}
	post.InitPost()

	like := like.Like{}
	like.InitLike()

	talk := talk.Talk{}
	talk.InitTalk()

	match := match.Match{}
	match.InitMatch()

	notification := notification.Notification{}
	notification.InitNotification()

	message := message.Message{}
	message.InitMessage()

	fs := http.FileServer(http.Dir("./assets"))
	http.Handle("/Images/", fs)
}
Example #2
0
func (match *Match) acceptMatch(request *restful.Request, response *restful.Response) {

	match.Validated = true
	match.ValidatedAt = time.Now()
	match.UserImageY = match.user.UrlPicture

	talk := new(talk.Talk)
	talk.MatchId = match.Id
	talk.UserIdX = match.UserIdX
	talk.UserIdY = match.UserIdY
	talk.UserNameX = match.UserNameX
	talk.UserNameY = match.UserNameY

	if talk.GetTalkByUsersId() == false {
		if err := talk.CreateTalk(); err != nil {
			response.WriteHeaderAndEntity(http.StatusConflict, err.Error())
			helpers.PrintLog(request, response, match.user.Name)
			return
		}
	}
	_, err := r.Table("matchs").Get(match.Id).Update(match).RunWrite(api.Sess)
	if err != nil {
		talk.RemoveTalk()
		response.WriteHeaderAndEntity(http.StatusConflict, err.Error())
		helpers.PrintLog(request, response, match.user.Name)
		return
	}
	go func() {
		notif := notification.SetAcceptMatchReceive()
		notif.UserId = match.UserIdX
		notif.UserIdFrom = match.user.Id
		notif.IdThing = match.Id
		notif.Name = match.UserNameY
		notif.IdLink = match.PostId
		notif.CreateNotification()
	}()

	render := AcceptMatch{Match: *match, Talk: *talk}
	response.WriteHeaderAndEntity(http.StatusOK, render)

	helpers.PrintLog(request, response, match.user.Name)
}