mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
email notifications management
This commit is contained in:
parent
be8ad1a888
commit
8a0e121f29
4 changed files with 69 additions and 1 deletions
|
@ -247,6 +247,19 @@ post '/settings/change_email' do
|
||||||
redirect '/settings#email'
|
redirect '/settings#email'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post '/settings/change_email_notification' do
|
||||||
|
require_login
|
||||||
|
|
||||||
|
owner = current_site.owner
|
||||||
|
|
||||||
|
owner.send_emails = params[:send_emails]
|
||||||
|
owner.send_comment_emails = params[:send_comment_emails]
|
||||||
|
owner.send_follow_emails = params[:send_follow_emails]
|
||||||
|
owner.save_changes validate: false
|
||||||
|
flash[:success] = 'Email notification settings have been updated.'
|
||||||
|
redirect '/settings#email'
|
||||||
|
end
|
||||||
|
|
||||||
post '/settings/create_child' do
|
post '/settings/create_child' do
|
||||||
require_login
|
require_login
|
||||||
|
|
||||||
|
|
|
@ -733,7 +733,7 @@ class Site < Sequel::Model
|
||||||
if can_email?(args[:col])
|
if can_email?(args[:col])
|
||||||
EmailWorker.perform_async({
|
EmailWorker.perform_async({
|
||||||
from: FROM_EMAIL,
|
from: FROM_EMAIL,
|
||||||
to: email,
|
to: owner.email,
|
||||||
subject: args[:subject],
|
subject: args[:subject],
|
||||||
body: args[:body]
|
body: args[:body]
|
||||||
})
|
})
|
||||||
|
|
|
@ -48,6 +48,22 @@ describe 'site/settings' do
|
||||||
@site.email.wont_equal @new_email
|
@site.email.wont_equal @new_email
|
||||||
EmailWorker.jobs.empty?.must_equal true
|
EmailWorker.jobs.empty?.must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should update email preferences' do
|
||||||
|
uncheck 'send_emails'
|
||||||
|
uncheck 'send_comment_emails'
|
||||||
|
uncheck 'send_follow_emails'
|
||||||
|
|
||||||
|
@site.send_emails.must_equal true
|
||||||
|
@site.send_comment_emails.must_equal true
|
||||||
|
@site.send_follow_emails.must_equal true
|
||||||
|
|
||||||
|
click_button 'Update Notification Settings'
|
||||||
|
@site.reload
|
||||||
|
@site.send_emails.must_equal false
|
||||||
|
@site.send_comment_emails.must_equal false
|
||||||
|
@site.send_follow_emails.must_equal false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'change password' do
|
describe 'change password' do
|
||||||
|
|
|
@ -10,3 +10,42 @@
|
||||||
<input class="btn-Action" type="submit" value="Change Email">
|
<input class="btn-Action" type="submit" value="Change Email">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<h2>Email Notification Settings</h2>
|
||||||
|
<form method="POST" action="/settings/change_email_notification">
|
||||||
|
<%== csrf_token_input_html %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Receive Emails:
|
||||||
|
<input name="send_emails" type="hidden" value="false">
|
||||||
|
<input name="send_emails" type="checkbox" value="true"
|
||||||
|
<% if current_site.owner.send_emails %>
|
||||||
|
checked
|
||||||
|
<% end %>
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Receive Comment Emails:
|
||||||
|
<input name="send_comment_emails" type="hidden" value="false">
|
||||||
|
<input name="send_comment_emails" type="checkbox" value="true"
|
||||||
|
<% if current_site.owner.send_comment_emails %>
|
||||||
|
checked
|
||||||
|
<% end %>
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Receive Follow Emails:
|
||||||
|
<input name="send_follow_emails" type="hidden" value="false">
|
||||||
|
<input name="send_follow_emails" type="checkbox" value="true"
|
||||||
|
<% if current_site.owner.send_follow_emails %>
|
||||||
|
checked
|
||||||
|
<% end %>
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input class="btn-Action" type="submit" value="Update Notification Settings">
|
||||||
|
</div>
|
||||||
|
</form>
|
Loading…
Add table
Reference in a new issue