Esempio 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,
	})
}
Esempio n. 2
0
func RoomsUnread(c *gin.Context) {
	user, err := GetUserFromContext(c)
	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{"unread": unread})
}