func (s *session) sendSnapshot(msgs []proto.Message, listing proto.Listing) error { for i, msg := range msgs { if msg.EncryptionKeyID != "" { dmsg, err := proto.DecryptMessage(msg, s.client.Authorization.MessageKeys) if err != nil { continue } msgs[i] = dmsg } } snapshot := &proto.SnapshotEvent{ Identity: s.Identity().ID(), SessionID: s.ID(), Version: s.room.Version(), Listing: listing, Log: msgs, } event, err := proto.MakeEvent(snapshot) if err != nil { return err } s.outgoing <- event return nil }
func (s *session) sendSnapshot() error { snapshot, err := s.room.Snapshot(s.ctx, s, s.privilegeLevel(), 100) if err != nil { return err } s.identity.name = snapshot.Nick for i, msg := range snapshot.Log { if msg.EncryptionKeyID != "" { dmsg, err := proto.DecryptMessage(msg, s.client.Authorization.MessageKeys, s.privilegeLevel()) if err != nil { continue } snapshot.Log[i] = dmsg } } s.identity.name = snapshot.Nick event, err := proto.MakeEvent(snapshot) if err != nil { return err } s.outgoing <- event return nil }