func (c *Client) InBandMessagesFromState(s gregor.State) ([]gregor.InBandMessage, error) { items, err := s.Items() if err != nil { return nil, err } var res []gregor.InBandMessage for _, i := range items { if ibm, err := c.sm.ObjFactory().MakeInBandMessageFromItem(i); err == nil { res = append(res, ibm) } } return res, nil }
func (m *MemEngine) InitState(s gregor.State) error { m.Lock() defer m.Unlock() items, err := s.Items() if err != nil { return err } now := m.clock.Now() for _, it := range items { user := m.getUser(it.Metadata().UID()) ibm, err := m.objFactory.MakeInBandMessageFromItem(it) if err != nil { return err } item := user.addItem(now, it) user.logMessage(nowIfZero(now, item.ctime), ibm, item) } return nil }