This file contains 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
sns = AWS::SNS.new(:access_key_id => AWSPUB,:secret_access_key => AWSPRI) | |
app_arn = server.is_sandbox? ? SNS_SANDBOX_APP_ARN : SNS_PRODUCTION_APP_ARN | |
timestamp = Time.new.strftime("%Y-%m-%d %H:%M:%S") | |
custom_user_data = "{\"user_id\":#{user.id},\"type\":\"#{token_type}\",\"update_ts\":\"#{timestamp}\"}" | |
if edit_endpoint # Edit existing endpoint | |
apn_token = AppleToken.find(:id => token_id) # AppleToken is the DB object in Sequel | |
if apn_token.nil? || apn_token.user_id != user.id | |
# Token ID not found for this user |
This file contains 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
def self.sendapns(apnsdata) | |
type = apnsdata['type'] | |
uid = apnsdata['userid'].to_i | |
endpoint_arn = get_endpoint_arn(uid) | |
notification = APNS_NOTIFICATIONS[type] # Get the notification fields from wherever you store them | |
if notification.nil? | |
@log.error("notification type '#{type}' not found") | |
return | |
end |
This file contains 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
#!/usr/bin/env ruby | |
# (1) Prevent any commit to production branches | |
PRODUCTION_BRANCHES = ["production"] | |
branch = `git rev-parse --abbrev-ref=strict HEAD`.chomp | |
if (PRODUCTION_BRANCHES.include?(branch)) | |
puts "\nDo you really want to commit on '#{branch}' branch?\nIf yes, add --no-verify to the commit command to force it." |