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 +}