Commit efe0b2ed authored by Fernando Takagi's avatar Fernando Takagi
Browse files

Correctly check for haystack parameter on console

parent a44f1ed4
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -36,8 +36,14 @@ func (s *ConsoleServer) ListChannelMessages(ctx context.Context, in *console.Lis
		return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.")
	}

	haystack := time.Unix(in.HaystackSec, 0).UTC()
	messageList, err := ChannelMessagesList(ctx, s.logger, s.db, uuid.Nil, *stream, channelId, limit, in.Forward, cursor, &haystack)
	var haystack *time.Time
	if in.HaystackSec != nil {
		h := time.Unix(in.HaystackSec.Value, 0).UTC()
		haystack = &h
	} else {
		haystack = nil
	}
	messageList, err := ChannelMessagesList(ctx, s.logger, s.db, uuid.Nil, *stream, channelId, limit, in.Forward, cursor, haystack)
	if err == runtime.ErrChannelCursorInvalid {
		return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.")
	} else if err != nil {