Commit Graph

27 Commits

Author SHA1 Message Date
Joel Hough b68984052d don't send summaries to bouncing channels
fixes CNVS-18827

test plan
- cause a summary message to be sent to a bouncing communication
 channel
- ensure that the message is not sent

Change-Id: I966a386c6d822db873c4dee19e061b5ca12d060a
Reviewed-on: https://gerrit.instructure.com/49376
Tested-by: Jenkins
Reviewed-by: Matthew Wheeler <mwheeler@instructure.com>
QA-Review: Derek Hansen <dhansen@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
2015-02-27 23:56:58 +00:00
Simon Williams fc31213935 fix creating delayed messages for retired communication channels
refs CNVS-16138

test plan:
- create a user, set up a communication channel, and set up a notification to
  be 'daily'
- retire the communication channel
- trigger the action that will create the daily notification
- manually trigger the delayed message summarizer job: `DelayedMessage.summarize([DelayedMessage.order(:created_at).last])`
- it should not create a summary message for the retired channel

Change-Id: Id29c6f7d437438894b2e7527ffe7fbe3c220cfda
Reviewed-on: https://gerrit.instructure.com/42380
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Matthew Wheeler <mwheeler@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Matthew Wheeler <mwheeler@instructure.com>
2014-10-10 20:14:54 +00:00
Cody Cutrer 95ecf20e73 use Rails' base_class
and remove base_ar_class, that does the same thing

Change-Id: Id76a2dcc375cfea397ff4b4853f50d660b6b044c
Reviewed-on: https://gerrit.instructure.com/41783
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-09-30 21:14:22 +00:00
Cody Cutrer 102fdfc849 no more dynamic finders (models)
refs CNVS-15126

Change-Id: I2996e0e262c41274c34d0ea3bfde757074416b8c
Reviewed-on: https://gerrit.instructure.com/40973
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-09-24 20:51:48 +00:00
Ethan Vizitei c4765bc2a0 gemify broadcast policy
fixes #CNVS-14270

move broadcast policy into a gem of its own
to remove plugin deprecation warnings.

TEST PLAN:
 -no behavior changes
 -regression test notifications
   (no need to hit them all, confirm that 3 or
   4 separate notifications flow and
    that will prove the pipeline)

Change-Id: If8445653ec09ab4d221124d85f9674d1cedd3751
Reviewed-on: https://gerrit.instructure.com/40899
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Matthew Wheeler <mwheeler@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
QA-Review: August Thornton <august@instructure.com>
2014-09-24 11:35:33 +00:00
Simon Williams f154fb1226 fix delayed message validation for alerts
fixes CNVS-15426

test plan:
- enable account alerts in account settings
- enroll a teacher in a course
- make sure the teacher has a verified email address
- visit the teacher's notification preferences page to make sure there is
  a notification policy set up for the alert notification.  confusingly, this
  is not the same as the "Alert" section on the page, this notification policy
  actually cannot be customized, but visiting the page will create it if it
  doesn't already exist.
- the annoying thing about this alert notification policy is setup is that it
  is set up to be a 'daily' policy, and it can't be customized.  this means
  that even after the job runs and creates the message successfully, it won't
  actually be sent until the following daily batch. to fix this for testing,
  you can make the notification policy immediate by running the following in
  a rails console:
    ```
    NotificationPolicy.
      where(:notification_id => Notification.by_name("Alert")).
      update_all(:frequency => "immediately")
    ```
- now set up an alert and trigger the conditions for the alert
- alert messages are only computed once per day at 11:30 utc. since this is an
  inconvenient time to have a patchset checked out, the easiest way to make
  this happen manually is to run the following in a rails conosle:
    `Alerts::DelayedAlertSender.process`
  however, be aware that this job sets a redis key after it runs to make sure
  notifications don't get sent twice to the same person, so if you do need to run
  it twice in one day for some reason, clear redis between runs.
- the alert message should actually be sent.  if you set up a real email
  address you should receive the message, or you can check that it was sent by
  using the "View Notifications" tab in the admin tools section of the account.

Change-Id: Ia3ca030da1896539c6ca193b87c1ce9d3b936ef9
Reviewed-on: https://gerrit.instructure.com/40919
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Liz Abinante <labinante@instructure.com>
QA-Review: Anna Koalenz <akoalenz@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2014-09-15 19:49:16 +00:00
Cody Cutrer 5f4dcccff4 avoid extraneous queries to Notification
just use the cached .all, even for associations

test plan:
 * go to the notification preferences page as a user
 * in console
   * np = NotificationPolicy.first; np.notification
   * the first time, it should query notification_policy,
     and *all* notifications
   * do it again, and this time it should not query
     notifications, but should still return an object

Change-Id: I3b83ec9ce6f6f6b4d542e83d2b8653b4e221afd4
Reviewed-on: https://gerrit.instructure.com/40460
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-09-09 21:54:16 +00:00
Cody Cutrer 1277aaae90 stabby lambda scopes for rails4
Change-Id: I34f2527471cdb4d8cab5cde426ba959baa26189e
Reviewed-on: https://gerrit.instructure.com/37151
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-07-04 02:11:56 +00:00
Braden Anderson 45d19f3003 validate types on polymorphic associations
fixes ALYT-26

test plan:
	* regression test

Change-Id: Ie93e89b842e354f1f76d75f3492145b86c79a035
Reviewed-on: https://gerrit.instructure.com/34560
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Braden Anderson <banderson@instructure.com>
2014-05-28 17:05:34 +00:00
Anthus Williams c247a3758d remove some of the less useful associations from export
delayed_messages, exports, imports, migrations,
stream_items, etc.

Change-Id: I6eb63457ad496d7aaf56fc9ec8a9602a5679fdd7
Reviewed-on: https://gerrit.instructure.com/35215
Reviewed-by: Braden Anderson <banderson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
2014-05-27 15:44:00 +00:00
Anthus Williams 828981e72c define exportable attributes/associations on models
instead of passing an :exportable option to
ActiveRecord::Associations, simply define a constant
on the class containing exportable associations and
attributes. This is due to :exportable breaking
ActiveRecord, and we can't simply monkey-patch in
config/initializers because models are included in
migrations before the initializers are run

Change-Id: I11f1a6b4570c397d8e01010c517bc6efdac7afca
Reviewed-on: https://gerrit.instructure.com/33235
Reviewed-by: Braden Anderson <banderson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
2014-05-06 23:54:24 +00:00
Derek DeVries 25f426b700 fix polymorphic quiz_submission association on delayed_message
fixes CNVS-12395

test plan:
  please check for regressions around notifications on quiz submissions.
  this includes:
  - to teachers when the submission needs grading
  - to students when the submission is graded
  - to students when the grade changed

this one is very difficult to reproduce manually. data needs to be in a state
where a delayed job has been queued to send a notification message for a quiz
submission before the namespace change was deployed, and then it attempts to
execute the delayed job after the namespace change. it appears that messages
are only sent to a delayed message queue when there there are more than 500
messages per day.

Change-Id: I0869b4decaec900a2c4c8df5c6e0b8b29dd08c5c
Reviewed-on: https://gerrit.instructure.com/33307
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Josh Simpson <jsimpson@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-04-15 21:48:48 +00:00
Anthus Williams f762e242ad summarize delayed_message on message's shard
instead of attempting to load the passed
DelayedMessage records whatever happens to be the
current shard

fixes CNVS-4568

test plan: specs should pass

Change-Id: I585e1bfb87be160608f7ae4f4c8f8f97d260ff69
Reviewed-on: https://gerrit.instructure.com/28366
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
2014-01-16 01:45:42 +00:00
Cody Cutrer d3f0b18684 validate nullness in the db on a bunch of columns
fixes CNVS-7414

Change-Id: I60978f66d88d916dc5736dbb975715172bd1e14b
Reviewed-on: https://gerrit.instructure.com/23141
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-09-12 22:20:39 +00:00
Cody Cutrer 8e6b3fd57c return time zone in user profile api
fixes CNVS-6280

refactors User#time_zone and Account#default_time_zone to return actual
time zone objects instead of strings.
Assignments to the fields accept both forms; reading the field prefers
to return a Rails friendly name, but the IANA name is easily accessible
from that object. Continue to use Rails names for the UI, but use
IANA names for the API.

test plan:
 * in the UI, ensure that you can change timezones and it persists
   correctly in the following locations:
   * user profile as the user
   * root account settings
   * user page as an admin
 * check the API responses for /api/v1/users/self/profile and
   /api/v1/accounts/self; the time zone should be listed as an
   IANA name (i.e. America/Denver, not Mountain Time)
 * Update an account (PUT /api/v1/accounts/self) to change the
   default time zone; ensure both friendly names and IANA names
   are accepted on input, but on output the IANA name is returned

Change-Id: Ib976e7e1b2dde2639ff6fd478a59b38fdb0d07c0
Reviewed-on: https://gerrit.instructure.com/22563
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-07-25 16:46:32 +00:00
Jon Willesen 495db783d5 Add API for admins to access user messages
There are three parts to this:
 - API access for site admins and account admins. Account
   admins can only see messages for their account.
 - Includes start and end time parameters for basic searching
 - Summary notification are gathered up per account now, so
   account admins will not see a summary notification from
   multiple accounts.

fixes CNVS-3695

test plan:
 - Verify Admin Access:
   - Have a user enrolled in two courses in separate root
     accounts.
   - Send the user ASAP notification from each account.
   - Go to /users/:id/messages (the old interface) and verify
     the messages appear there.
   - As a site admin, get /api/v1/comm_messages for the user
     (see documentation for the api).
   - Verify that data for both messages are returned.
   - Use the console to give an account admin on one of the
     accounts :read_messages permissions.
   - As the account admin, get /api/v1/comm_messages for the
     user.
   - Verify that only the message for the admin's account is
     returned.
 - Verify start_time and end_time parameters
   - Use the console to modify the created_at field for the
     user's messages
   - As a site admin, get /api/v1/comm_messages for the user,
     specifying various combinations of start_time and
     end_time, and make sure the appropriate messages are
     returned.
 - Verify account based summaries
   - Set the notification policies for the user to a summary
     setting (daily or weekly)
   - Send multiple notifications to the user from each account.
   - Use the console to run the
     SummaryMessageConsolidator::process function.
   - View /messages for the user and verify that separate
     summaries are sent for each account.

Change-Id: Ie33ec02cc2033a1cc2f1fcbe538b76792aab0e6c
Reviewed-on: https://gerrit.instructure.com/18586
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Mark Ericksen <marke@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
Product-Review: Marc LeGendre <marc@instructure.com>
2013-04-11 19:38:02 +00:00
Eric Berry ffd0fe56c3 HTMLify the outbound email messages and update the /messages UI
All of the outbound email notifications have been updated to have
a matching HTML version of the email in order for us to send multi-
part emails. There has also been some tweaking of the other email
messages (summary, plain text, etc) with a better looking layout

fixes CNVS-4728
fixes CNVS-4795

test steps:
- generate email messages for each template and review the results
  in the users message list view (/users/1/messages)

Change-Id: I1fd9cf2b134209e42c8d174f19b50963e6502f6a
Reviewed-on: https://gerrit.instructure.com/18942
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Product-Review: Eric Berry <ericb@instructure.com>
2013-04-03 20:03:34 +00:00
Cody Cutrer 8c94e53dc7 arel-ify scopes
s/named_scope/scope/g

refs CNVS-4707

Change-Id: I930d229fc9985c7c0096a0f4888933addd4f3aee
Reviewed-on: https://gerrit.instructure.com/18834
Reviewed-by: Duane Johnson <duane@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-04-01 21:57:16 +00:00
Cody Cutrer d9111f5414 arel-ify models
closes CNVS-4707

Change-Id: I32c8ec5a53525f89cf232890eaac790fbc2b4744
Reviewed-on: https://gerrit.instructure.com/18745
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-04-01 18:42:38 +00:00
Zach Pendleton 46e5b9027d remove body, sms_body columns from notifications.
fixes CNVS-3917

the notifications table had vestigial `body` and `sms_body`
columns that canvas no longer uses. this commit drops those
columns.

test plan:
  * back up your database (unless you want to keep this
    commit on your master branch forever);
  * run migrations;
  * verify that notifications still send as expected;
  * for extra credit, configure canvas with a new database
    and verify that db:initial_setup still works without
    any errors.

Change-Id: Icc7d8c4e926b5ea0ecb8c3814fdc95481037a0c9
Reviewed-on: https://gerrit.instructure.com/17892
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
Reviewed-by: Mark Ericksen <marke@instructure.com>
2013-02-22 16:07:21 -07:00
Cody Cutrer 16a53809c8 create messages from DelayedMessage.summarize on the user's shard
fixes CNVS-1714

test plan:
 * do an action that goes through DelayedMessage.summarize
   (I think just means setting some notifications to every 5 minutes
    or something)
 * wait the five minutes
 * the message(s) should show up in /users/x/messages

Change-Id: Ibcc646f9ec869543b8ba84c1d7c7f8171ce55d78
Reviewed-on: https://gerrit.instructure.com/17166
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
2013-02-04 10:50:57 -07:00
Jacob Fugal 88f41882ba spread weekly notifications over saturdays
notifications were happening on monday because
TimeWithZone.advance(:days => x) does nothing. move them to saturday for
real and also spread them over the Eastern-time day instead of lumping
them all at 8pm (admittedly by timezone, but that's only 4 hours for the
continental US, which is the current majority of users).

add an indicator to the notification preference page to show a rough
time block in which they can expect their weekly messages to be sent.

fixes #8296

test-plan:
  setup:
  - create two accounts the same id but on different shards (shard ids
    should not differ by a multiple of four)
  - in each a account, create a user with a communication channel; call
    them Alice and Bob.
  - create a third account on the same shard as Bob's account but with a
    different id (account ids should not differ by a multiple of four)
  - in this account create two users with a communication channel each;
    call them Charles and David.
  - for each of the four users, assign a notification to deliver to the
    user's communication channel weekly
  - on Friday, trigger the associated notifications for each user
  - on Sunday, trigger David's notification again

  expectations:
  - each user should receive the messages on saturday (Eastern-time),
    not monday
  - Alice's and Bob's emails should arrive in different "quarter days"
  - Bob's and Charle's emails should arrive in different "quarter days"
  - Charles' email and David's first email should arrive in the same
    "quarter day" but in different hours
  - David's emails should come a week apart, but in the same hour both
    times

  UI:
  - go to the notifications preference page
  - should see note at bottom indicating two hour block during which
    their weekly notifications will be sent
  - actual send time of weekly notifications should fall within that
    block

Change-Id: I97bb75762ef8c03fae99ad5499b441f7c026d2c8
Reviewed-on: https://gerrit.instructure.com/13963
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-27 15:24:13 -06:00
Jon Jensen f63077aa7f cache notifications in memory
test plan:
* use canvas and ensure that notifications work

Change-Id: Ie46f049aab5dde7167c3ea4228e503c7a686c839
Reviewed-on: https://gerrit.instructure.com/9154
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-03-05 14:49:27 -07:00
Brian Palmer 69e1ac6b6f fix two common delayed job errors
* trying to auto assign peer reviews for an assignment that never had,
   or no longer has, a due_at
 * trying to process a delayed message for a context that has already
   been deleted since the job was scheduled

Change-Id: I090252a07cd616918bf664a326c33772aa3893dd
Reviewed-on: https://gerrit.instructure.com/4312
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
2011-07-06 12:37:43 -06:00
Cody Cutrer bdbebfaec8 check all models for protecting attributes refs #3847
Change-Id: I7cba6e26ad98e91723e2ccf0a28b8db79bb37b5c
Reviewed-on: https://gerrit.instructure.com/3631
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-05-25 17:38:50 -06:00
tom metge 28dbe009ff fix sqlite compatibility for delayed_jobs-related queries
Change-Id: I13004a50207401c4b8a990dce5cfa2ec3871a102
Reviewed-on: https://gerrit.instructure.com/2256
Reviewed-by: Brian Whitmer <brian@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2011-02-11 12:56:46 -07:00
Brian Whitmer 8b8173dcc9 Initial commit.
closes #6988138
2011-01-31 18:57:29 -07:00