small bugfixes for services refactor
This commit is contained in:
parent
8fe2eb3180
commit
9d37b2a749
3 changed files with 3 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ class Service
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
||||||
def public_message(post, length, url = "")
|
def public_message(post, length, url = "")
|
||||||
|
url = "" if post.respond_to?(:photos) && post.photos.count == 0
|
||||||
space_for_url = url.blank? ? 0 : (url.length + 1)
|
space_for_url = url.blank? ? 0 : (url.length + 1)
|
||||||
truncated = truncate(post.message, :length => (length - space_for_url))
|
truncated = truncate(post.message, :length => (length - space_for_url))
|
||||||
truncated = "#{truncated} #{url}" unless url.blank?
|
truncated = "#{truncated} #{url}" unless url.blank?
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class Services::Twitter < Service
|
class Services::Twitter < Service
|
||||||
MAX_CHARACTERS = 140
|
MAX_CHARACTERS = 140
|
||||||
<D-F>url
|
|
||||||
def post(post, url='')
|
def post(post, url='')
|
||||||
Rails.logger.debug("event=post_to_service type=twitter sender_id=#{self.user_id}")
|
Rails.logger.debug("event=post_to_service type=twitter sender_id=#{self.user_id}")
|
||||||
message = public_message(post, url)
|
message = public_message(post, url)
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ class User
|
||||||
def post_to_services(post, url)
|
def post_to_services(post, url)
|
||||||
if post.public && post.respond_to?(:message)
|
if post.public && post.respond_to?(:message)
|
||||||
self.services.each do |service|
|
self.services.each do |service|
|
||||||
service.post(post.message)
|
service.post(post, url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue