feat: autogenerate vapid keys for push notifications (#3128)
* feat: Autogenerate push notification keys * add vapid service class and remove pushkey model * add spec for vapid service * unset vapid env keys * Unset VAPID_PRIVATE_KEY env variable Co-authored-by: Sojan Jose <sojan@chatwoot.com> Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
This commit is contained in:
@@ -28,6 +28,7 @@ class DashboardController < ActionController::Base
|
||||
'ANALYTICS_HOST'
|
||||
).merge(
|
||||
APP_VERSION: Chatwoot.config[:version],
|
||||
VAPID_PUBLIC_KEY: VapidService.public_key,
|
||||
ENABLE_ACCOUNT_SIGNUP: GlobalConfigService.load('ENABLE_ACCOUNT_SIGNUP', 'false')
|
||||
)
|
||||
end
|
||||
|
||||
@@ -34,5 +34,4 @@ describe('campaignMixin', () => {
|
||||
const wrapper = shallowMount(Component);
|
||||
expect(wrapper.vm.isOnOffType).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import events from 'widget/api/events';
|
||||
|
||||
const state = {
|
||||
isOpen: false,
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
create: async (_, { name }) => {
|
||||
@@ -17,7 +17,7 @@ const actions = {
|
||||
const mutations = {
|
||||
toggleOpen($state) {
|
||||
$state.isOpen = !$state.isOpen;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
@@ -43,7 +43,7 @@ class Notification::PushNotificationService
|
||||
end
|
||||
|
||||
def send_browser_push?(subscription)
|
||||
ENV['VAPID_PUBLIC_KEY'] && subscription.browser_push?
|
||||
VapidService.public_key && subscription.browser_push?
|
||||
end
|
||||
|
||||
def send_browser_push(subscription)
|
||||
@@ -56,8 +56,8 @@ class Notification::PushNotificationService
|
||||
auth: subscription.subscription_attributes['auth'],
|
||||
vapid: {
|
||||
subject: push_url,
|
||||
public_key: ENV['VAPID_PUBLIC_KEY'],
|
||||
private_key: ENV['VAPID_PRIVATE_KEY']
|
||||
public_key: VapidService.public_key,
|
||||
private_key: VapidService.private_key
|
||||
},
|
||||
ssl_timeout: 5,
|
||||
open_timeout: 5,
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
hostURL: '<%= ENV.fetch('FRONTEND_URL', '') %>',
|
||||
fbAppId: '<%= ENV.fetch('FB_APP_ID', nil) %>',
|
||||
signupEnabled: '<%= @global_config['ENABLE_ACCOUNT_SIGNUP'] %>',
|
||||
<% if ENV['VAPID_PUBLIC_KEY'] %>
|
||||
vapidPublicKey: new Uint8Array(<%= Base64.urlsafe_decode64(ENV['VAPID_PUBLIC_KEY']).bytes %>),
|
||||
<% if @global_config['VAPID_PUBLIC_KEY'] %>
|
||||
vapidPublicKey: new Uint8Array(<%= Base64.urlsafe_decode64(@global_config['VAPID_PUBLIC_KEY']).bytes %>),
|
||||
<% end %>
|
||||
enabledLanguages: <%= available_locales_with_name.to_json.html_safe %>,
|
||||
selectedLocale: '<%= I18n.locale %>'
|
||||
|
||||
Reference in New Issue
Block a user