Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push notification #425

Merged
merged 12 commits into from
Aug 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/build/*
**/node_modules/*
**/tmp/*
/private/certs/*
*.bak
*.iml
*.ipr
Expand Down
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ todda00:friendly-slugs
underscorestring:underscore.string
yasaricli:slugify
yasinuslu:blaze-meta
raix:[email protected]
2 changes: 2 additions & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ percolate:[email protected]
percolatestudio:[email protected]
qnub:[email protected]
raix:[email protected]
raix:[email protected]
raix:[email protected]
raix:[email protected]
raix:[email protected]
[email protected]
[email protected]
Expand Down
29 changes: 29 additions & 0 deletions client/lib/cordova/push.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
if Meteor.isCordova
if RocketChat.settings.get('Push_enable') is true
Push.Configure {}

Push.addListener 'token', (token) ->
Meteor.call 'log', 'token', arguments

Push.addListener 'error', (err) ->
Meteor.call 'log', 'error', arguments
if error.type == 'apn.cordova'
Meteor.call 'log', err.error

Push.addListener 'register', (evt) ->
Meteor.call 'log', 'register', arguments

Push.addListener 'alert', (notification) ->
Meteor.call 'log', 'alert', arguments

Push.addListener 'sound', (notification) ->
Meteor.call 'log', 'sound', arguments

Push.addListener 'badge', (notification) ->
Meteor.call 'log', 'badge', arguments

Push.addListener 'startup', (notification) ->
Meteor.call 'log', 'startup', arguments

Push.addListener 'message', (notification) ->
Meteor.call 'log', 'message', arguments
8 changes: 4 additions & 4 deletions client/views/settings/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ Template.settings.helpers

Template.settings.events

"click .submit": ->
"click .submit": (e, t) ->
group = FlowRouter.getParam('group')
settings = Settings.find({ group: group }).fetch()
updateSettings = []
for setting in settings
value = null
if setting.type is 'string'
value = _.trim($("input[name=#{setting._id}]").val())
else if setting.type is 'boolean' and $("input[name=#{setting._id}]:checked").length
value = if $("input[name=#{setting._id}]:checked").val() is "1" then true else false
value = _.trim(t.$("[name=#{setting._id}]").val())
else if setting.type is 'boolean' and t.$("[name=#{setting._id}]:checked").length
value = if t.$("[name=#{setting._id}]:checked").val() is "1" then true else false

if value?
updateSettings.push { _id: setting._id, value: value }
Expand Down
6 changes: 5 additions & 1 deletion client/views/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ <h3>{{description}}</h3>
<div class="input-line double-col">
<label>{{label}}</label>
<div>
<input type="text" name="{{_id}}" value="{{value}}" />
{{#if multiline}}
<textarea name="{{_id}}" rows="4" style="height: auto">{{value}}</textarea>
{{else}}
<input type="text" name="{{_id}}" value="{{value}}" />
{{/if}}
</div>
</div>
{{/if}}
Expand Down
12 changes: 6 additions & 6 deletions mobile-config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This section sets up some basic app metadata,
// the entire section is optional.
App.info({
id: 'com.konecty.rocketchat',
name: 'Rocket.Chat',
description: 'Rocket.Chat',
author: 'Rocket.Chat Development Group',
email: '[email protected]',
website: 'https://rocket.chat'
id: 'com.konecty.rocket.chat',
name: 'Rocket.Chat',
description: 'Rocket.Chat',
author: 'Rocket.Chat Development Group',
email: '[email protected]',
website: 'https://rocket.chat'
});

// Set up resources such as icons and launch screens.
Expand Down
13 changes: 7 additions & 6 deletions packages/rocketchat-lib/settings/server/methods.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ RocketChat.settings.add = (_id, value, options = {}) ->
if not _id or not value?
return false

console.log '[functions] RocketChat.settings.add -> '.green, 'arguments:', arguments
# console.log '[functions] RocketChat.settings.add -> '.green, 'arguments:', arguments

if Meteor.settings?[_id]?
value = Meteor.settings[_id]

updateSettings =
i18nLabel: options.i18nLabel or _id
i18nDescription: options.i18nDescription if options.i18nDescription?

updateSettings.type = options.type if options.type
updateSettings.multiline = options.multiline if options.multiline
updateSettings.group = options.group if options.group
updateSettings.public = options.public if options.public

return Settings.upsert { _id: _id }, { $setOnInsert: { value: value }, $set: updateSettings }

###
Expand All @@ -33,7 +34,7 @@ RocketChat.settings.addGroup = (_id, options = {}) ->
if not _id
return false

console.log '[functions] RocketChat.settings.addGroup -> '.green, 'arguments:', arguments
# console.log '[functions] RocketChat.settings.addGroup -> '.green, 'arguments:', arguments

updateSettings =
i18nLabel: options.i18nLabel or _id
Expand All @@ -50,6 +51,6 @@ Meteor.methods
unless user?.admin is true
throw new Meteor.Error 503, 'Not authorized'

console.log "saveSetting -> ".green, _id, value
# console.log "saveSetting -> ".green, _id, value
Settings.update { _id: _id }, { $set: { value: value } }
return true
11 changes: 11 additions & 0 deletions packages/rocketchat-lib/settings/server/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ Meteor.startup ->
RocketChat.settings.add 'Meta:robots', '', { type: 'string', group: 'Meta' }
RocketChat.settings.add 'Meta:google-site-verification', '', { type: 'string', group: 'Meta' }
RocketChat.settings.add 'Meta:msvalidate.01', '', { type: 'string', group: 'Meta' }

RocketChat.settings.addGroup 'Push'
RocketChat.settings.add 'Push_debug', false, { type: 'boolean', group: 'Push' }
RocketChat.settings.add 'Push_enable', false, { type: 'boolean', group: 'Push' }
RocketChat.settings.add 'Push_production', false, { type: 'boolean', group: 'Push' }
RocketChat.settings.add 'Push_apn_passphrase', '', { type: 'string', group: 'Push' }
RocketChat.settings.add 'Push_apn_key', '', { type: 'string', multiline: true, group: 'Push' }
RocketChat.settings.add 'Push_apn_cert', '', { type: 'string', multiline: true, group: 'Push' }
RocketChat.settings.add 'Push_apn_dev_passphrase', '', { type: 'string', group: 'Push' }
RocketChat.settings.add 'Push_apn_dev_key', '', { type: 'string', multiline: true, group: 'Push' }
RocketChat.settings.add 'Push_apn_dev_cert', '', { type: 'string', multiline: true, group: 'Push' }
24 changes: 24 additions & 0 deletions server/lib/cordova.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Meteor.methods
log: ->
console.log.apply console, arguments

Meteor.startup ->

Push.debug = RocketChat.settings.get 'Push_debug'

if RocketChat.settings.get('Push_enable') is true
Push.Configure
apn:
passphrase: RocketChat.settings.get 'Push_apn_passphrase'
keyData: RocketChat.settings.get 'Push_apn_key'
certData: RocketChat.settings.get 'Push_apn_cert'
'apn-dev':
passphrase: RocketChat.settings.get 'Push_apn_dev_passphrase'
keyData: RocketChat.settings.get 'Push_apn_dev_key'
certData: RocketChat.settings.get 'Push_apn_dev_cert'
gateway: 'gateway.sandbox.push.apple.com'
production: RocketChat.settings.get 'Push_production'
badge: true
sound: true
alert: true
vibrate: true
1 change: 1 addition & 0 deletions server/startup/i18n-validation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ flat = (obj, newObj = {}, path = '') ->


Meteor.startup ->
return
l = {}
keys = {}
errors = []
Expand Down