docbrown/app/services/bufferizer/listings_tweet.rb
Alex a7376ad10d
Move Bufferizer to services (#12171)
* Create Bufferizer::MainTweet service

* Create Bufferizer::SatelliteTweet service

* Rename text to tweet

* Create Bufferizer::FacebookPost service

* Create Bufferizer::ListingsTweet service

* Remove old Bufferizer

* Update spec wording

* Update admin_id argument

* Use constants for size limits
2021-01-08 11:17:20 -05:00

24 lines
585 B
Ruby

module Bufferizer
class ListingsTweet
TWEET_SIZE_LIMIT = 255
def self.call(listing, tweet)
return unless listing && tweet
buffer_listings_id = ApplicationConfig["BUFFER_LISTINGS_PROFILE"]
BufferUpdate.send_to_buffer(
listings_twitter_text(tweet, listing),
buffer_listings_id,
)
listing.update(last_buffered: Time.current)
end
def self.listings_twitter_text(tweet, listing)
"#{tweet} #{URL.url(listing.path)}" if tweet.size <= TWEET_SIZE_LIMIT
end
private_class_method :listings_twitter_text
end
end