// MakeChatReportForUser returns ChatReport for an user.
// If not joined, Messages and Users fields are always empty.
// Chat should be locked. LoggedDB, MessageDB should be unlocked.

MakeChatReportForUser returns ChatReport for an user.
If not joined, Messages and Users fields are always empty.
Chat should be locked. LoggedDB, MessageDB should be unlocked.
// MakeChatReportForUser returns ChatReport for an user . // If not joined Messages and Users fields are always empty . // Chat should be locked . LoggedDB MessageDB should be unlocked .
func (s *Store) MakeChatReportForUser(username string, chatname string) ChatReport {
	res := NewChatReport(username, chatname, s.ChatDB.IsInChat(chatname, username))
	if res.Joined {
		gotMessages, err := s.MessageDB.GetLastNMessages(chatname, config.C.LastMessages)
		if err == nil {
			res.Messages = gotMessages
		}
		for _, u := range s.ChatDB.GetUsers(chatname) {
			if loggedU, err := s.LoggedDB.Get(u); err == nil {
				userToAppend := models.NewUserWithStatus(loggedU.User, loggedU.UserStatus)
				res.Users = append(res.Users, userToAppend)
			}
		}
	}
	return res
}
func ( s * Store ) MakeChatReportForUser ( username string , chatname string ) ChatReport { res := NewChatReport ( username , chatname , s . ChatDB . IsInChat ( chatname , username ) ) if res . Joined { gotMessages , err := s . MessageDB . GetLastNMessages ( chatname , config . C . LastMessages ) if err == nil { res . Messages = gotMessages } for _ , u := range s . ChatDB . GetUsers ( chatname ) { if loggedU , err := s . LoggedDB . Get ( u ) ; err == nil { userToAppend := models . NewUserWithStatus ( loggedU . User , loggedU . UserStatus ) res . Users = append ( res . Users , userToAppend ) } } } return res }
MakeChatReportForUser returns ChatReport for an user.
MakeChatReportForUser returns ChatReport for an user .