Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

User#tell

  • Loading branch information...
commit aa435249cdca4e6f0244e96e9f317e160bfa601b 1 parent 9866fb4
Mike Burns mike-burns authored
36 app/models/message.rb
View
@@ -83,9 +83,9 @@ def self.handle_incoming(phone_number, message_text)
def self.handle_texting_proxy(user, message)
if dating_user = user.date
- Message.deliver(user.date.phone_number, "#{user.name} says: #{message}")
+ user.date.tell("#{user.name} says: #{message}")
else
- Message.deliver(user.phone_number, "You have no date for us to share that with. Reply with '#{COMMANDS[:new_date]}'.")
+ user.tell("You have no date for us to share that with. Reply with '#{COMMANDS[:new_date]}'.")
end
end
@@ -94,8 +94,7 @@ def self.handle_new_date(user)
user.founded_meetups.proposed.destroy_all
if user.founded_meetups.unscheduled.any?
- Message.deliver(user.phone_number,
- "Whoa there, pardner - we're looking for someone right now. If nobody shows after 5 minutes, then you can ask again.")
+ user.tell("Whoa there, pardner - we're looking for someone right now. If nobody shows after 5 minutes, then you can ask again.")
else
user.offers.cancel_all
@@ -105,8 +104,7 @@ def self.handle_new_date(user)
})
- Message.deliver(user.phone_number,
- "Should we find you a date at #{meetup.description}? Reply 'ok' or 'new date' to try again.")
+ user.tell("Should we find you a date at #{meetup.description}? Reply 'ok' or 'new date' to try again.")
QUEUE.enqueue_at(5.minutes.from_now, OkTimeoutMessageDelayer, :user_id => user.id)
end
else
@@ -121,8 +119,7 @@ def self.within_dating_hours?
end
def self.outside_dating_hours(user)
- Message.deliver(user.phone_number,
- "Outside of the dating hours: #{DATING_START_STRING} to #{DATING_END_STRING}. Please try again then!")
+ user.tell("Outside of the dating hours: #{DATING_START_STRING} to #{DATING_END_STRING}. Please try again then!")
end
def self.handle_ok(user)
@@ -139,8 +136,7 @@ def self.handle_ok(user)
end
def self.handle_unknown(user)
- Message.deliver(user.phone_number,
- "Sorry, I don't know what to do with that. You can text '#{COMMANDS[:new_date]}' to get a date. To stop receiving texts, please text '#{COMMANDS[:quit]}'")
+ user.tell("Sorry, I don't know what to do with that. You can text '#{COMMANDS[:new_date]}' to get a date. To stop receiving texts, please text '#{COMMANDS[:quit]}'")
end
@@ -150,13 +146,11 @@ def self.handle_accept(user)
meetup = accepted_offer.meetup
meetup.pending_offers.each do |offer|
- Message.deliver(offer.offered_user.phone_number,
- "Too slow! Would you like to get a date? Reply '#{COMMANDS[:new_date]}'.")
+ offer.offered_user.tell("Too slow! Would you like to get a date? Reply '#{COMMANDS[:new_date]}'.")
offer.decline!
end
else
- Message.deliver(user.phone_number,
- "You don't have any date offers to accept")
+ user.tell("You don't have any date offers to accept")
end
end
@@ -168,13 +162,11 @@ def self.accept_offer(offer)
end
def self.deliver_date(first_user, second_user)
- Message.deliver(first_user.phone_number,
- %{Nice! You've got a date with #{second_user.name}, '#{second_user.description}'. Say something by texting '#{COMMANDS[:sext]}' and then your message.})
+ first_user.tell(%{Nice! You've got a date with #{second_user.name}, '#{second_user.description}'. Say something by texting '#{COMMANDS[:sext]}' and then your message.})
end
def self.handle_safeword(user)
- Message.deliver(user.phone_number,
- "I got it - 'no' means no! We could just be friends, but we're not fooling anyone. You're unsubscribed - have a nice life!")
+ user.tell("I got it - 'no' means no! We could just be friends, but we're not fooling anyone. You're unsubscribed - have a nice life!")
user.destroy
end
@@ -188,11 +180,9 @@ def self.handle_dfln(user, message)
def self.handle_no_responses(user)
meetup = user.founded_meetups.unscheduled.first
if !meetup.nil?
- Message.deliver(user.phone_number,
- "We called every number in our little black book, but only got answering machines. Try again later? Reply '#{COMMANDS[:new_date]}' to start again.")
+ user.tell("We called every number in our little black book, but only got answering machines. Try again later? Reply '#{COMMANDS[:new_date]}' to start again.")
meetup.offers.pending.each do |offer|
- Message.deliver(offer.offered_user.phone_number,
- "Too slow! Would you like to get a date? Reply '#{COMMANDS[:new_date]}'.")
+ offer.offered_user.tell("Too slow! Would you like to get a date? Reply '#{COMMANDS[:new_date]}'.")
offer.cancel!
end
meetup.cancel!
@@ -202,7 +192,7 @@ def self.handle_no_responses(user)
def self.handle_ok_timeout(user)
meetup = user.founded_meetups.proposed.first
if !meetup.nil?
- Message.deliver(user.phone_number,"I guess you don't want to go on a date... Text '#{COMMANDS[:new_date]}' again when you change your mind")
+ user.tell("I guess you don't want to go on a date... Text '#{COMMANDS[:new_date]}' again when you change your mind")
meetup.state = "cancelled"
meetup.save
end
4 app/models/morning_after_checker_upper.rb
View
@@ -10,10 +10,10 @@ def self.perform(args_hash)
meetup = Meetup.find(meetup_id)
- Message.deliver(meetup.first_user.phone_number,
+ meetup.first_user.tell(
"Hey #{meetup.first_user.name}, how did it go last night with #{meetup.second_user.name}? Respond to this text to let us know.")
- Message.deliver(meetup.second_user.phone_number,
+ meetup.second_user.tell(
"Hey #{meetup.second_user.name}, how did it go last night with #{meetup.first_user.name}? Respond to this text to let us know.")
Dfln.create(:meetup => meetup, :user => meetup.first_user, :text => nil)
3  app/models/offer.rb
View
@@ -39,7 +39,6 @@ def schedule_meetup!
private
def send_message
- Message.deliver(offered_user.phone_number,
- "Want to go on a date with #{meetup.first_user.name} at #{meetup.description}? Reply '#{COMMANDS[:accept]}' or ignore.")
+ offered_user.tell("Want to go on a date with #{meetup.first_user.name} at #{meetup.description}? Reply '#{COMMANDS[:accept]}' or ignore.")
end
end
12 app/models/user.rb
View
@@ -104,7 +104,7 @@ def matching
end
def deliver_secret_code
- Message.deliver(self.phone_number,
+ self.tell(
"Before you can become an instalover you must know this secret code: '#{self.secret_code}'. " +
"Visit instalover.com to finish signing up.")
end
@@ -113,6 +113,10 @@ def latest_offer
offers.pending.first
end
+ def tell(msg)
+ Message.deliver(self.phone_number, msg)
+ end
+
protected
def normalize_phone_number
@@ -124,8 +128,7 @@ def phone_number_new
user = User.find_by_phone_number(self.phone_number)
if !user.nil?
if user.confirmed?
- Message.deliver(user.phone_number,
- "You are already a user - text '#{COMMANDS[:new_date]}' to start getting dates and '#{COMMANDS[:quit]}' to quit")
+ user.tell("You are already a user - text '#{COMMANDS[:new_date]}' to start getting dates and '#{COMMANDS[:quit]}' to quit")
else
user.deliver_secret_code
end
@@ -194,8 +197,7 @@ def just_updated_for_the_first_time?
def deliver_confirmation_congratulations
if just_updated_for_the_first_time?
- Message.deliver(self.phone_number,
- "Congrats, #{self.name}, you are now an instalover. Text '#{COMMANDS[:new_date]}' to get a new date.")
+ self.tell("Congrats, #{self.name}, you are now an instalover. Text '#{COMMANDS[:new_date]}' to get a new date.")
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.