Live video on the AT Protocol

atproto: fix block nil pointer

+10 -1
+1 -1
pkg/atproto/sync.go
··· 74 74 return fmt.Errorf("failed to create block: %w", err) 75 75 } 76 76 block, err = atsync.Model.GetBlock(ctx, rkey.String()) 77 - if err != nil { 77 + if err != nil || block == nil { 78 78 return fmt.Errorf("failed to get block after we just saved it?!: %w", err) 79 79 } 80 80 streamplaceBlock, err := block.ToStreamplaceBlock()
+9
pkg/model/block.go
··· 23 23 } 24 24 25 25 func (b *Block) ToStreamplaceBlock() (*streamplace.Defs_BlockView, error) { 26 + if b == nil { 27 + return nil, fmt.Errorf("block is nil") 28 + } 29 + if b.Repo == nil { 30 + return nil, fmt.Errorf("block repo is nil") 31 + } 32 + if b.Record == nil { 33 + return nil, fmt.Errorf("block record is nil") 34 + } 26 35 rec, err := lexutil.CborDecodeValue(b.Record) 27 36 if err != nil { 28 37 return nil, fmt.Errorf("error decoding feed post: %w", err)