Commit Graph

160 Commits

Author SHA1 Message Date
Penar Musaraj
102909edb3 FEATURE: Add support for secure media (#7888)
This PR introduces a new secure media setting. When enabled, it prevent unathorized access to media uploads (files of type image, video and audio). When the `login_required` setting is enabled, then all media uploads will be protected from unauthorized (anonymous) access. When `login_required`is disabled, only media in private messages will be protected from unauthorized access. 

A few notes: 

- the `prevent_anons_from_downloading_files` setting no longer applies to audio and video uploads
- the `secure_media` setting can only be enabled if S3 uploads are already enabled and configured
- upload records have a new column, `secure`, which is a boolean `true/false` of the upload's secure status
- when creating a public post with an upload that has already been uploaded and is marked as secure, the post creator will raise an error
- when enabling or disabling the setting on a site with existing uploads, the rake task `uploads:ensure_correct_acl` should be used to update all uploads' secure status and their ACL on S3
2019-11-18 11:25:42 +10:00
Sam Saffron
e7cf4579a8 DEV: improve usability of subfolder specs
Previously people were not consistent about mocking which left internals in
a fragile state when running subfolder specs.

This introduces a simple helper `set_subfolder` which you can use to set
the subfolder for the spec. It takes care of proper configuration of subfolder
and teardown.

```
# usage
set_subfolder "/my_amazing_subfolder"
```

You should no longer stub base_uri or global_settings
2019-11-15 16:48:24 +11:00
Neil Lalonde
4c2d6e19ba PERF: cache new users counts in summary emails
The query to count how many new users there are since a given date
is expensive. It's the least personalized stat and the one we fallback
to last when no better number can be found for the target user.
Give up accuracy so we can aggressively cache the user counts
that appear in this email.
2019-10-25 16:33:36 -04:00
Krzysztof Kotlarek
32b8a2ccff DEV: Upgrade Discourse to Rails 6 (#8083)
* Adjustments to pass specs on Rails 6.0.0
* Use classic autoloader instead of Zeitwerk
* Update Rails 6.0.0 deprecated methods
* Rails 6.0.0 not allowing column with integer name
* Drop freedom_patches/rails6.rb
* Default value for trigger_transactional_callbacks? is true
* Bump rspec-rails version to 4.0.0.beta2
2019-09-12 10:41:50 +10:00
Neil Lalonde
4b9d35cd0e FEATURE: add option to always send excerpts in emails
Enable the new setting "post excerpts in emails" to send excerpts
instead of complete posts in notification emails. Control the length of
excerpts with the "post excerpt maxlength" setting.
2019-08-06 12:45:28 -04:00
Neil Lalonde
9656a21fdb
FEATURE: customization of html emails (#7934)
This feature adds the ability to customize the HTML part of all emails using a custom HTML template and optionally some CSS to style it. The CSS will be parsed and converted into inline styles because CSS is poorly supported by email clients. When writing the custom HTML and CSS, be aware of what email clients support. Keep customizations very simple.

Customizations can be added and edited in Admin > Customize > Email Style.

Since the summary email is already heavily styled, there is a setting to disable custom styles for summary emails called "apply custom styles to digest" found in Admin > Settings > Email.

As part of this work, RTL locales are now rendered correctly for all emails.
2019-07-30 15:05:08 -04:00
Robin Ward
66214eee85 SECURITY: Strip HTML from invite emails
We also strip new lines from the emails because it ruins the markdown
formatting which expects a one line message.
2019-07-05 14:57:11 -04:00
Gerhard Schlager
b788948985 FEATURE: English locale with international date formats
Makes en_US the new default locale
2019-05-20 13:47:20 +02:00
Daniel Waterworth
e219588142 DEV: Prefabrication (test optimization) (#7414)
* Introduced fab!, a helper that creates database state for a group

It's almost identical to let_it_be, except:

 1. It creates a new object for each test by default,
 2. You can disable it using PREFABRICATION=0
2019-05-07 13:12:20 +10:00
Guo Xiang Tan
152238b4cf DEV: Prefer public_send over send. 2019-05-07 09:33:21 +08:00
Sam Saffron
4ea21fa2d0 DEV: use #frozen_string_literal: true on all spec
This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
2019-04-30 10:27:42 +10:00
Gerhard Schlager
197e3fd722 FIX: Keep original subject in emails to staged users
Renaming a topic shouldn't be visibile to staged users when the topic was created via email.
2019-01-18 11:07:54 +01:00
Gerhard Schlager
15d1e981c8 DEV: Improve specs
* notifications were created for the wrong user
* notifications didn't have a correct data attribute
2019-01-18 11:07:53 +01:00
Gerhard Schlager
c0a8bb9a91 FEATURE: Include "via <site_name>" in email From header 2019-01-04 17:06:19 +01:00
Gerhard Schlager
2c5d9269a0 FIX: Notifications shouldn't use user locale unless allow_user_locale is enabled 2018-09-05 11:44:28 +02:00
Osama Sayegh
0b7ed8ffaf FEATURE: backend support for user-selectable components
* FEATURE: backend support for user-selectable components

* fix problems with previewing default theme

* rename preview_key => preview_theme_id

* omit default theme from child themes dropdown and try a different fix

* cache & freeze stylesheets arrays
2018-08-08 14:46:34 +10:00
Neil Lalonde
4e6e4a83df FIX: subfolder digest emails have incorrect URLs 2018-08-07 16:38:17 -04:00
Guo Xiang Tan
87537b679c Drop reply_key, skipped and skipped_reason from email_logs. 2018-07-30 11:39:28 +08:00
Maja Komel
0942e2c795 allow adding tags as a custom subject format for emails (#5846)
allow adding tags as a custom subject format for emails
2018-07-11 12:24:07 +10:00
Jeff Wong
4599cc8435 FIX: PM participants listed inline 2018-06-11 18:14:25 -07:00
Guo Xiang Tan
77eb93ffb7 Fabricate records with the right attributes during fabrication. 2018-05-07 11:26:38 +08:00
Jeff Wong
62a8904729
Feature: Include participants at the bottom of PM emails (#5797)
* Feature: Include participants at the bottom of PM emails

... as undecorated links.

https://meta.discourse.org/t/email-notification-recipients-unclear-when-pm-is-sent-to-multiple-users/26934/13?u=featheredtoast

Fix: missing translation for PM mentions

* display membership count as `group (count)`
2018-05-03 15:50:06 -07:00
Leo McArdle
89f41f8236 FIX: error when group_in_subject enabled but no group in pm 2018-03-11 12:22:11 +00:00
Guo Xiang Tan
1b5d955a34 Fix the build. 2018-02-26 12:46:15 +08:00
Leo McArdle
5d9d0fcb4f FEATURE: add setting which adds group name to PM email subject (#5475) 2018-02-19 10:20:17 +01:00
Erick Guan
03b3e57a44 FEATURE: login by a link from email
Co-authored-by: tgxworld <tgx@discourse.org>
2018-02-13 16:14:39 +08:00
Guo Xiang Tan
5805979e88 FIX: Re-enable invalid interpolation keys check and allow default keys to be left out of translation overrides.
https://meta.discourse.org/t/bulk-invite-from-file-resets-the-invite-forum-mailer-customized-text/67606/16
2017-11-27 11:00:08 +08:00
Neil Lalonde
94d8f6d734 FIX: digest emails should not include posts that are still in the edit grace period 2017-08-14 12:47:33 -04:00
Guo Xiang Tan
5012d46cbd Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
Guo Xiang Tan
b59dfb86f4 UX: Include group name in email when group is invited to a PM.
https://meta.discourse.org/t/xyz-invited-you-to-a-message-but-really-invited-a-group-im-in/65996
2017-07-26 15:51:44 +09:00
Arpit Jalan
16d356ab4e FEATURE: resending invite should include original custom message
https://meta.discourse.org/t/will-resent-invite-include-original-custom-message/64699
2017-06-30 18:13:33 +05:30
Guo Xiang Tan
cae09ee4c8 Fix failing specs. 2017-06-16 09:39:54 +09:00
Guo Xiang Tan
92036616db Make test less vulnerable to changes. 2017-05-17 19:30:13 +08:00
Guo Xiang Tan
3df46833b3 Fix the build. 2017-05-17 16:14:06 +08:00
Guo Xiang Tan
71a266b673 Remove daily mailing mode option as it doesn't scale.
https://meta.discourse.org/t/daily-updates-option-for-mailing-list-mode/45029/14?u=tgxworld
2017-05-05 12:21:50 +08:00
Neil Lalonde
389a0e1a1c FIX: emails should use default theme colors 2017-05-03 14:35:13 -04:00
Robin Ward
bf9c4a7828 FEATURE: secure_email site setting to prevent data going out in email 2017-04-26 13:05:56 -04:00
Neil Lalonde
402ddb810c FIX: email customizations now apply to both html and text parts 2017-03-10 14:08:03 -05:00
Arpit Jalan
dc2171960b FIX: allow existing users to be invited to topic/message when must_approve_users is enabled 2017-02-03 13:01:23 +05:30
Neil Lalonde
e8307ac24c FIX: mailing list mode digest emails included whispers 2017-01-13 13:46:33 -05:00
Neil Lalonde
74956694e5 If summary email finds no topics, show topics more than 1 day old from new users 2016-12-19 14:54:08 -05:00
Neil Lalonde
985daf5c72 FIX: summary should not include certain post types 2016-12-01 12:01:32 -05:00
Neil Lalonde
79dc0518c9 FIX: popular posts in digest need to use same restrictions as topics 2016-11-23 11:24:18 -05:00
Neil Lalonde
86deec3528 FIX: exclude popular posts from deleted topics 2016-11-22 13:23:21 -05:00
Sam
115c454002 FIX: if prioritizing names in ux choose name over username in email 2016-11-14 11:09:24 +11:00
Régis Hanol
829143bf88 FIX: 'List-Unsubscribe' header wasn't added to emails sent when mailing_list_mode was enabled 2016-08-01 20:19:00 +02:00
Régis Hanol
7848a84e0e FIX: ensure summary emails have the 'List-Unsubscribe' header set 2016-07-15 11:39:29 +02:00
Robin Ward
5f91919663 Email support for watching first post 2016-07-07 12:23:19 -04:00
Arpit Jalan
40e9e1be66 FEATURE: user-friendly custom message 2016-06-08 18:23:22 +05:30
Arpit Jalan
4253141700 FEATURE: custom email message for topic invites 2016-06-07 23:43:15 +05:30
Arpit Jalan
7b205ebba4 FEATURE: customize invite email message 2016-06-06 20:15:30 +05:30
James Kiesel
feffe23cc5 FEATURE: More granular mailing list mode (#4068)
* Rearrange frontend to account for mailing list mode

* Allow update of user preference for mailing list frequency

* Add mailing list frequency estimate

* Simplify frequency estimate; disable activity summary for mailing list mode

* Remove combined updates

* Add specs for enqueue mailing list mode job

* Write mailing list method for mailer

* Fix linting error

* Account for stale topics

* Add translations for default mailing list setting

* One query for mailing list topics

* Fix failing spec

* WIP

* Flesh out html template

* First pass at text-based mailing list summary

* Add user avatar

* Properly format posts for mailing list

* Move make_all_links_absolute into Email::Styles

* Apply first_seen_at to user

* Send mailing list email summary hourly based on first_seen_at

* Branch and test cleanup

* Use existing mailing list mode estimate

* Fix failing specs
2016-05-21 15:17:54 +02:00
Sam
c095304d6d FEATURE: limit daily emails per user to 100 per day via site setting
- controlled via max_emails_per_day_per_user, 0 to disable
- when limit is reached user is warned
2016-03-23 15:08:48 +11:00
Robin Ward
5771d2aee2 SECURITY: Support for confirm old as well as new email accounts 2016-03-08 14:52:22 -05:00
scossar
5b5076c61d test for empty string 2016-03-04 20:20:58 -08:00
scossar
2d8b10d139 validate user locale 2016-03-04 13:21:30 -08:00
scossar
a20a52b25f add user locale 2016-03-03 17:21:50 -08:00
Sam Saffron
820a435af8 FEATURE: add "email in-reply-to user option"
We no longer include previous replies as "context", instead
we include and excerpt of the post being replied to at the bottom
of notifications, this information was previously missing.

Users may opt in to emailing previous replies if they wish
or opt out of "in-reply-to" which makes sense in some email clients that
are smarter about displaying a tree of replies.
2016-02-26 00:05:59 +11:00
Sam
ab06f86fbe FEATURE: allow users to control how many previous replies they get
- always means we always send previous replies with every email
- never means we do not
- "unless previously sent" ... is the default, in which we only email you each reply once

The default_email_previous_replies site setting can control this toggle
2016-02-19 13:57:07 +11:00
Régis Hanol
c740b42328 FIX: whitelist post_types used in context in email notifications 2016-02-12 12:10:30 +01:00
Arpit Jalan
82a75c00c0 UX: change 'Visit Topic' to 'Visit Message' for message notification email 2016-02-09 13:39:10 +05:30
Régis Hanol
7d992cb4c5 FIX: sending emails to mailing list subscribers wasn't working 2016-02-03 19:27:58 +01:00
Régis Hanol
378b7f964c Revert "FEATURE (WIP): add max-width and center email notifications" 2016-01-29 11:13:59 +01:00
scossar
017820e445 check for template 2016-01-27 18:39:20 -08:00
Sam
1bb485fca5 FIX: when a user got multiple replies to a topic, emails were missing 2016-01-27 12:20:08 +11:00
Sam
a2b72cc767 correct specs 2016-01-12 13:56:58 +11:00
Andy Waite
3e50313fdc Prepare for separation of RSpec helper files
Since rspec-rails 3, the default installation creates two helper files:
* `spec_helper.rb`
* `rails_helper.rb`

`spec_helper.rb` is intended as a way of running specs that do not
require Rails, whereas `rails_helper.rb` loads Rails (as Discourse's
current `spec_helper.rb` does).

For more information:

https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#default-helper-files

In this commit, I've simply replaced all instances of `spec_helper` with
`rails_helper`, and renamed the original `spec_helper.rb`.

This brings the Discourse project closer to the standard usage of RSpec
in a Rails app.

At present, every spec relies on loading Rails, but there are likely
many that don't need to. In a future pull request, I hope to introduce a
separate, minimal `spec_helper.rb` which can be used in tests which
don't rely on Rails.
2015-12-01 20:39:42 +00:00
Arpit Jalan
5180d3e355 FEATURE: include email_prefix in digest email subject instead of site title 2015-06-03 22:22:29 +05:30
Arpit Jalan
b33654ac31 Remove site setting stubbing (Round 1) 2015-06-03 15:44:00 +05:30
Arpit Jalan
d9ec6888e1 FIX: allow site_name to be present in rejection email subject 2015-05-04 11:22:54 +05:30
Arthur Neves
439d0d2e37
Check Rails.version instead of ENV
Like that we can have code that works on multiple Rails versions, and we
dont need to mix a new method on Kernel.
Also, this makes easier to have multiple versions.
For instance, before master was 4.2, which is not the case anymore, so
on the code we should check versions and not Environment variables
2015-04-28 22:27:47 -04:00
Arpit Jalan
8c2d7dcaac FEATURE: invite existing user to a topic 2015-04-03 15:00:04 +05:30
Arpit Jalan
6e5540c107 FIX: do not show name in email if name on posts are disabled 2015-02-18 01:39:41 +05:30
Arpit Jalan
7771d2fb31 remove enable_email_names setting 2015-01-13 13:35:40 +05:30
Luciano Sousa
b3d769ff4f Update rspec syntax to v3
update rspec syntax to v3

change syntax to rspec v3

oops. fix typo

mailers classes with rspec3 syntax

helpers with rspec3 syntax

jobs with rspec3 syntax

serializers with rspec3 syntax

views with rspec3 syntax

support to rspec3 syntax

category spec with rspec3 syntax
2015-01-05 11:59:30 -03:00
Arpit Jalan
f84bdfdde3 FIX: if full user name is not provided, username should be present in email From header 2014-12-03 13:12:05 +05:30
Godfrey Chan
bddaf8193a HAX: check the message object, not the MessageDelivery object
See 669bf73 for background. It's probably better to rewrite these test without
using the internal `NullMail` class anyway.
2014-11-10 01:05:47 -08:00
Godfrey Chan
568ed3beaa HAX: force the lazy MessageDelivery object to create the mailer
Starting from Rails 4.2, calling MyMailer.some_method no longer result in an
immediate call to MyMailer#some_method. Instead, a "lazy proxy" is returned
(this is changed to support #deliver_later). As a quick hack to fix the test,
calling #message (or anything, really) would force the Mailer object to be
created and the method invoked.
2014-11-10 01:05:46 -08:00
Régis Hanol
ada750b384 fixed some more deprecations. 20 to go 2014-10-29 16:06:50 +01:00
Arpit Jalan
8700716fcd separate site setting for showing full name in emails 2014-10-22 00:50:39 +05:30
Arpit Jalan
83068fab94 FEATURE: show full name in emails 2014-10-21 23:34:44 +05:30
Arpit Jalan
20c2480eb3 FIX: fix broken test 2014-10-07 01:23:39 +05:30
Arpit Jalan
0ae0552543 FEATURE: show topic category in email subject 2014-10-03 22:08:59 +05:30
Arpit Jalan
330b7ba54a FEATURE: add site preference for standard subjects, including support for Re 2014-09-29 21:54:29 +05:30
Régis Hanol
de76b512c1 fix most deprecations in the specs (still some left) 2014-09-25 17:44:48 +02:00
Arpit Jalan
2f6c984c8c Improve invite email copy 2014-07-10 10:57:40 +05:30
Arpit Jalan
8395da5bd0 FIX: include topic title and domain name in topic invite mail 2014-07-10 10:05:28 +05:30
Arpit Jalan
223bbc3da3 FEATURE: include topic context in topic invite 2014-07-09 21:23:20 +05:30
Neil Lalonde
f44bd4ec28 Don't allow sending private messages to suspended users. Emails to suspended users should tell them how to respond, since they can't. 2014-05-06 15:01:27 -04:00
Robin Ward
64faee0935 Break down new topic counts by category if a digest contains many. 2014-04-17 16:42:40 -04:00
Sam
adb6541635 FEATURE: mailing list mode always available 2014-03-05 14:21:53 +11:00
Sam
9ec52d9425 BUGFIX: mailing list mode broke regular email 2014-02-12 16:51:26 +11:00
Sam
5267e5bea6 BUGFIX: emails sent from "2 replies" as opposed to correct user 2014-02-04 12:56:28 +11:00
Sam
51c06dea03 BUGFIX: hidden posts not absent from context 2014-01-31 16:37:40 +11:00
Sam
db1d01d1a2 Discourse as a Mailing List improvements
FEATURE: context is not emailed if we previously emailed you the post
FEATURE: site setting to enable_watch_new_topics , false by default.
  When enables users can elect to watch everything by default
FIX: Custom email subjects (x quoted you in [title], x replied to [title])
  was removed, this broke email grouping. TBD, include info in footer somehow
FIX: topic user specs were messy, reduce side effects
2013-12-30 13:02:12 +11:00
Robin Ward
8c8645f158 FIX: Code and Emoticon formatting in HTML emails. 2013-11-28 17:21:14 -05:00
Sam
4599e5d732 oops did not have autospec running 2013-09-12 15:55:18 +10:00
Neil Lalonde
baff59d752 Send email to contact_email when a new version of Discourse is found. Disable with the new_version_emails setting. 2013-08-16 17:28:36 -04:00
Sam
d51dcd1705 improve email styling, include extra respond link 2013-07-26 17:27:46 +10:00
Robin Ward
3e7b418ea8 First Try: Include Post History (context) in Notification Emails 2013-07-22 15:06:37 -04:00