func (c Rooms) Show(roomkey string) revel.Result { if !isLogin(c.Controller) { c.Flash.Error("Please login first") return c.Redirect(Sessions.New) } currentUser := CurrentUser(c.Controller) room := model.FindRoomByRoomKey(roomkey) activeRoom := ChatServer.GetActiveRoom(roomkey) activeRoom.AddUserToRecent(currentUser) log.Println(currentUser.Email) // user list users := activeRoom.UserList() // room list rooms := model.FindRoomByUserId(currentUser.Id) // user avatar userAvatar := currentUser.AvatarUrl() // gem latest message latestMessages := room.LatestMessage() log.Println("latest message len is:", len(latestMessages)) return c.Render(room, users, userAvatar, rooms, latestMessages) }
func (c Rooms) Edit(roomkey string) revel.Result { if !isLogin(c.Controller) { c.Flash.Error("Please login first") return c.Redirect(Application.Index) } room := model.FindRoomByRoomKey(roomkey) return c.Render(room) }
func (c Rooms) Update(roomkey string, updateroom *form.UpdateRoom) revel.Result { if !isLogin(c.Controller) { c.Flash.Error("Please login first") return c.Redirect(Application.Index) } room := model.FindRoomByRoomKey(roomkey) if err := room.Update(updateroom); err != nil { c.Flash.Error(err.Error()) return c.Redirect("/r/%s/edit", room.RoomKey) } c.Flash.Success("update success") return c.Redirect("/r/%s/edit", room.RoomKey) }