Exemplo n.º 1
0
func RoomsIndex(c *gin.Context) {
	user, err := GetUserFromContext(c)
	if err != nil {
		c.Fail(500, err)
	}

	rooms, err := models.FindRooms(user.TeamId)
	if err != nil {
		c.Fail(500, err)
	}

	memberships, err := models.FindRoomMemberships(user.Id)
	if err != nil {
		c.Fail(500, err)
	}

	unread, err := models.UnreadRooms(user.Id)
	if err != nil {
		c.Fail(500, err)
	}

	c.JSON(200, gin.H{
		"rooms":        rooms,
		"memberships":  memberships,
		"unread_rooms": unread,
	})
}
Exemplo n.º 2
0
// RoomsTeamIndex simply fetches all of the rooms that have
// been created for the given team.
func RoomsTeamIndex(c *gin.Context) {
	teamID := models.FindTeamBySlug(c.Params.ByName("slug")).Id
	rooms, err := models.FindRooms(teamID)
	if err != nil {
		c.Fail(500, err)
	}

	c.JSON(200, gin.H{
		"rooms": rooms,
	})
}