Last active
August 29, 2015 14:24
-
-
Save piyushrajput/26a459097796a6de1cfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # search for feed items that match text and are parented by record_id, | |
| # e.g. a specific group or record feed. page_size must be a number between | |
| # 1 and 100. This method doesn't handle paging, so in most cases you'll want to also | |
| # add a page parameter to the query and continue to page even though no posts appear | |
| # for the searched group in some pages. | |
| def self.search_feed(user, record_id, text, page_size=100) | |
| escaped_text = URI.escape(text, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) | |
| items = Session.do_get(user, "/chatter/feed-items?q=#{escaped_text}&pageSize=#{page_size}") | |
| # filter out items that are not part of the searched group | |
| output = [] | |
| items['items'].each do |item| | |
| output << item if item['parent']['id'] == record_id | |
| end | |
| output | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment