Created
August 30, 2010 20:04
-
-
Save raykrueger/557963 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
diff --git a/lib/outbound_message_extensions.rb b/lib/outbound_message_extensions.rb | |
index fb5c759..4b5c425 100644 | |
--- a/lib/outbound_message_extensions.rb | |
+++ b/lib/outbound_message_extensions.rb | |
@@ -7,16 +7,25 @@ class OutboundMessage | |
# messages to unverified mobile numbers. | |
# | |
def self.create(attributes = {}, publish_options = {}) | |
+ instance = nil | |
if attributes[:account_id].nil? | |
- super | |
+ instance = super | |
else | |
account = Account.find(attributes[:account_id]) | |
mobile_phone = attributes[:mobile_phone] || attributes[:user][:mobile_phone] | |
trial = account.trial? | |
if !trial || (trial && account.verified_mobile_phone?(mobile_phone)) | |
- super | |
+ instance = super | |
end | |
end | |
+ | |
+ if instance | |
+ instance.class.send(:after_publish, :message_published) | |
+ end | |
+ end | |
+ | |
+ def message_published(message) | |
+ UserSmsMessage.create(:user_id => self.user_id, :message_ref => self.message_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment