From a57da00936ba89ffe3af0f66fba97ead877412ad Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 20 Jun 2014 11:30:30 -0700 Subject: [PATCH] search: add is:post and is:checkin Change-Id: I0d7c5f969de5a5c6bbf6dfd7acfb4774f0a00d4a --- pkg/search/predicate.go | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/pkg/search/predicate.go b/pkg/search/predicate.go index eafa99809..9ffbc1159 100644 --- a/pkg/search/predicate.go +++ b/pkg/search/predicate.go @@ -117,6 +117,10 @@ func init() { registerKeyword(newIsPortait()) registerKeyword(newWidth()) + // Custom predicates + registerKeyword(newIsPost()) + registerKeyword(newIsCheckin()) + // Location predicates registerKeyword(newHasLocation()) registerKeyword(newLocation()) @@ -628,3 +632,47 @@ func mimeFromFormat(v string) (string, error) { } return "", fmt.Errorf("Unknown format: %s", v) } + +// Custom predicates + +type isPost struct { + matchEqual +} + +func newIsPost() keyword { + return isPost{"is:post"} +} + +func (k isPost) Description() string { + return "matches tweets, status updates, blog posts, etc" +} + +func (k isPost) Predicate(ctx *context.Context, args []string) (*Constraint, error) { + return &Constraint{ + Permanode: &PermanodeConstraint{ + Attr: "camliNodeType", + Value: "twitter.com:tweet", + }, + }, nil +} + +type isCheckin struct { + matchEqual +} + +func newIsCheckin() keyword { + return isCheckin{"is:checkin"} +} + +func (k isCheckin) Description() string { + return "matches location check-ins (foursquare, etc)" +} + +func (k isCheckin) Predicate(ctx *context.Context, args []string) (*Constraint, error) { + return &Constraint{ + Permanode: &PermanodeConstraint{ + Attr: "camliNodeType", + Value: "foursquare.com:checkin", + }, + }, nil +}