Commit Graph

36 Commits

Author SHA1 Message Date
James Williams 6a3c885d92 rails4: rename Notification.all to all_cached
'all' is a scope in rails 4 that 'where' and
 other methods delegate to

refs #CNVS-21596

Change-Id: I62bb115fa7158438937d1ee54c83b2e0fb17eba1
Reviewed-on: https://gerrit.instructure.com/57441
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2015-07-01 17:23:22 +00:00
Joel Hough bca69aaef8 dependent destroy communication channel's notification policies and delayed messages
fixes CNVS-18976

test plan
- create communication channel
- set notification preferences to 'daily' for some notification
- cause a message of that type to be sent (i.e. queued for sending
 later)
- destroy! the communication channel from the console
- ensure that the channel is destroyed

Change-Id: I10e58c9381bf9307e0fc0c5c870ccbfc24671314
Reviewed-on: https://gerrit.instructure.com/49842
Reviewed-by: Matthew Wheeler <mwheeler@instructure.com>
Tested-by: Jenkins
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
2015-03-05 17:03:38 +00:00
Cody Cutrer 6364bcce87 ensure all notification policy creation handles unique constraint violations
fixes CNVS-15746

also removed some dead notification policy creation code

test plan:
 * configure notification preferences through facebook
 * it should work

Change-Id: Ide6e1d53767159b7946edcc23168f9683c04ee19
Reviewed-on: https://gerrit.instructure.com/44003
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-12-02 18:56:33 +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
Cody Cutrer bd5a9950d5 use RecordNotUnique, not UniqueConstraintViolation
since it's built into Rails 3

Change-Id: I55fba469a963538305f50b473bb05215ab5184d8
Reviewed-on: https://gerrit.instructure.com/40975
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-09-15 23:24:52 +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 ddfaf2fcbf transaction on the policy shard, not notification shard
notification is unsharded, so it would always be on the default shard

Change-Id: I7c821ff9e8a6827708e680432ba24972a3c329ce
Reviewed-on: https://gerrit.instructure.com/39450
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-08-18 19:27:28 +00:00
Cody Cutrer 6706a69c81 drop notification_policies.broadcast
it's never used

NotificationPolicy#preference also becomes obsolete, because NOT NULL
and FK ensure that #communication_channel can never be nil; it's
also never used

Change-Id: I0669d3b89964ee6f6d4c6a62e348e276bb7ef315
Reviewed-on: https://gerrit.instructure.com/39446
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-08-18 19:27:05 +00:00
James Williams 81558f728c remove rails 2 support
closes #CNVS-14261

Change-Id: I1b0e8a4438ab659ecd1ac8462bc3559d810989b3
Reviewed-on: https://gerrit.instructure.com/38744
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-08-06 18:16:19 +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
Joel Hough d9318b8e42 fix notification policy lookup in find_all_for
fixes CNVS-12319

Change-Id: Ib51e9b76cd0b054026553ea1e86bb276506cb926
Reviewed-on: https://gerrit.instructure.com/34707
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Reviewed-by: Drew Bowman <dbowman@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
2014-05-16 16:40:50 +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
Cody Cutrer c8a598d7cc fix NotificationPolicy.setup_for to be shard safe
Change-Id: I45b9f0c7fcf2bd75ee9a45155d2fb7eb9332a049
Reviewed-on: https://gerrit.instructure.com/31154
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-03-05 21:54:02 +00:00
Cody Cutrer fc60771d78 create summary messages on the user's shard
Change-Id: I35324dac349907031c0737a8eb9f4d2f9444255f
Reviewed-on: https://gerrit.instructure.com/30090
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-02-13 21:13:25 +00:00
Jon Willesen 0679f707b5 rails3: fixes in notification policy setup_for
Change-Id: Ib8738dd308bd159d7d7b60aa334577e011757c37
Reviewed-on: https://gerrit.instructure.com/29587
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
Product-Review: Jon Willesen <jonw@instructure.com>
QA-Review: Jon Willesen <jonw@instructure.com>
2014-02-07 21:39:07 +00:00
Cody Cutrer 6ff358abca notification preferences API
closes CNVS-5797

test plan:
 * GET /api/v1/users/self/communication_channels/:id/notification_preferences
   should return your preferences
 * GET .../notification_preferences/<one of the named notifications returned above>
   should return a single preference
 * PUT .../notification_preferences/<notification>?notification_preferences[frequency]=never
   should update it (will return it, and confirm by getting it again
 * PUT .../notification_preferences?notification_preferences[<notification>][frequency]=never&
   notification_preferences[<another notification>][frequency]=never
   should update two preferences at once
 * other allowed frequencies are immediately, daily, and weekly
 * repeat replacing the communication channel's id by email/<email address>
 * repeat by using an actual user id instead of self. users should
   not be able to view or update each other's preferences. admins
   should only be able to view, not update (the update routes only exist for "self",
   so you'll get a 404 instead of a 401 for them)
 * regression test notification preferences UI

Change-Id: I107f68a44cb68ee1675ad50ff7123e26d7765450
Reviewed-on: https://gerrit.instructure.com/26311
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-12-20 22:44:02 +00:00
Jacob Fugal a5d8bb8041 limit fake_arel caveats to rails2
refs CNVS-4704

fake_arel gets us most of the way to rails3's arel, but with some
caveats. the workarounds (mostly) work in both, but it'll be nice to not
have them crufting around when we're on rails3. so only use the
workarounds in CANVAS_RAILS2 branches.

Change-Id: Ia1f5cfa6b10f83cdb8d9a6e397b12401d180118d
Reviewed-on: https://gerrit.instructure.com/26331
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
2013-11-19 19:46:30 +00:00
Jacob Fugal dfab0425e3 use CANVAS_RAILS2 for conditionals
rather than CANVAS_RAILS3 or Rails.version

this is to be consistent, and to reinforce that any "special" branches
are for rails 2.3 backwards compatibility while trying to target rails
3, rather than rails 3 "forwards compatibility".

Change-Id: I4494b65e3f71108a43d09032c1569c478646a828
Reviewed-on: https://gerrit.instructure.com/24998
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
2013-10-10 15:58:43 +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 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
Joe Tanner 0333be64aa adding optional user arg to #default_frequency for use in a plugin
refs #CNVS-2648

Change-Id: Ie51025406679a1af314fc9438c3f56d124b6faec
Reviewed-on: https://gerrit.instructure.com/17039
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Cam Theriault <cam@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2013-01-29 09:29:38 -07:00
Jeremy Stanley 4682d65d1b exclude retired CCs in NotificationPolicy.for(User)
fixes #10422

test plan:
 * set up daily or weekly notifications to an address
   for a certain notification category
 * delete that address
 * set up a different address, and set notifications
   for the same category to "never"
 * make sure the notification to the old address
   is not received

note that the old/new addresses could conceivably be the same
(they are in the ticket), but that's tricky to set up because
the UI will prefer to reactivate the old address rather than
create a new one with the same name

Change-Id: I908d37ae4d587afad38eb9332df4ab7c31f36f7a
Reviewed-on: https://gerrit.instructure.com/13778
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
2012-09-18 16:18:31 -06:00
Simon Williams df277a6ad9 fix creating default notification policies
fixes #9966
refs #9901

there was a bug where policies for non-default channels were being considered
when deciding whether a default policy needed to be created, to show on the
communication preferences page.

also prevent an exception from being thrown when a user has no communication
channels, and visits the notification preferences page. We still need some
better UI here explaining why you can't do anything on the page.

test plan:
(for #9966)
- create a new user with an email, and setup some notification preferences
- add a new email address and retire the first one
- go to the notification preferences page
- you should have default preferences for the (new) default channel

(for #9901)
- as a user with no communication channels
- go to the notification preferences page
- it should not break

Change-Id: Iecd544571d6fece2a23c24b547ae434e8b57daae
Reviewed-on: https://gerrit.instructure.com/12952
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-08-16 09:32:26 -06:00
Simon Williams 4635521fe5 fix default notification policies for sharding
fixes #9942

notifications is an unsharded table, so we can't join it again notification
policies. switch to include to get expected behavior

test plan:
- on a non-default shard
- change all of your notification frequencies
- they should stay changed.

Change-Id: Ife74a2124567381e3d1898f1d34ca09904d7376d
Reviewed-on: https://gerrit.instructure.com/12937
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-08-15 17:07:36 -06:00
Mark Ericksen 2ce8bee3ca Load system notification policy defaults for new user. Fixes #9737
When a new user visits /profile/communication, load the
system defaults for frequency settings.

Test Plan
=======
* Create a new user and visit /profile/communication.
  Verify that there are default settings loaded.
* Verify that after adding a new communication channel
  that defaults are not applied.
* Verify that changing a setting and reloading
  preserves the user-selected value and is not
  overriden by a default.

Change-Id: I9d87b316510fd08bdf40380e05b327bed7e0e95c
Reviewed-on: https://gerrit.instructure.com/12720
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-08-03 14:54:43 -06:00
Mark Ericksen fbb927a83a Explicitly save "never" frequency on NotificationPolicy. Closes #9720
Previously, the rewritten Notification's page was deleting any
entries set to "never". However, some entries and code revert to the default behavior if no setting is recorded. This just makes each "never" setting be explicitly stored if set by the user.

Testing Plan:
============
* As a student set all notifications to "Do not send me anything"
* As a teacher create a new conference
* As a teacher go to Calendar -> Scheduler -> and create an appointment group
* Check the notification messages for the student
* Ensure that the student does not receive a notification message. (/users/x/messages)

Change-Id: Idbe4ad0d8b0394217787b5684161ab5987123e60
Reviewed-on: https://gerrit.instructure.com/12706
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-08-03 13:19:49 -06:00
Mark Ericksen acf8a779ef Update NotificationPolicy setting for all notifications in category.
Refs #8066, refs #9643.

Fix notification problem where making a 'category' frequency change
did not change the settings for all the notification events in the category.
Changed notification check box text per product's request.
Added new unit-test spec for updating multiple notification settings
for the same shared category.

Testing notes:
==============
Multiple Notifications in the same category should be updated when
the category displayed is changed. For instance, "Due Date" has
two notifications in that category.

One is "Assignment Due Date Changed" and the other is "Assignment Created".

There are two different ways to verify this. One is more technical but
easier to verify. The other is all UI driven but more complicated.

Technical Approach
------------------
* Find all notification IDs in the category "Due Date":

    id_list = Notification.find_all_by_category('Due Date').map(&:id)

* Find the CommunicationChannel for a given email address:

    channel = CommunicationChannel.find_by_path_and_path_type('jimbo@instructure.com', 'email')

* Find the NotificationPolicy entries for the category and channel:

    channel.notification_policies.scoped(:conditions => {:notification_id => id_list}).all

* Make a change to "/profile/communication" settings for "Due Date".
* Re-run the last query for listing the 2 NotificationPolicy entries. They should
  both be updated to have the new frequency.

Non-Technical Approach
----------------------
* Make a change to trigger each event in the "Due Date" group. (listed above in Testing Notes).
* Verify that changing "Due Date" to a setting like "Daily" and triggering
  the event that the notification is done as "Daily".
* Change the category frequency to something like "ASAP" and trigger the two events
  in the category and verify that both are respected as "Immediate/ASAP".

Change-Id: I9e0473c92206b2ec43ba1c1a6a0ec4c62cdae115
Reviewed-on: https://gerrit.instructure.com/12562
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-07-31 09:55:15 -06:00
Cody Cutrer bc48b1ef34 normalize user_id out of notification_policies
fixes #6585, #7096

by normalizing, it's impossible to not maintain a column that isn't
there (yes, triple negative is intended in that sentence), thus
preventing sending notifications to the wrong user after a merge
or any other bugs that would have missing maintaining the
denormalization.

test plan:
 * test notifications in general
 * merge two active users together - their notification preferences
   should survive the merge

Change-Id: I239d810c5499b94550b65128cac71c42cedd11ba
Reviewed-on: https://gerrit.instructure.com/8013
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
2012-02-01 12:42:23 -07:00
Cody Cutrer 0369527db4 fix saving notification preferences with score notifications disabled
closes #6114

test plan:
 * disable "Students can opt-in to receiving scores in email
   notifications", then try to update your notification preferences

Change-Id: I47df45da741fbbc349b746c590b5d5a25feab7f5
Reviewed-on: https://gerrit.instructure.com/7040
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2011-11-18 08:56:59 -07:00
Brian Palmer 92feb2bcdb replace ActiveRecord::Base calls with subclass calls where it makes sense
This was already a small issue if the job queue was on a different
database driver than the main database, and it'll become more important
as more AR connections are introduced.

Change-Id: I204becadd32bb935df096e8c937a04bb6962f0b2
Reviewed-on: https://gerrit.instructure.com/4601
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2011-07-18 13:56:08 -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
Cody Cutrer d143e152a7 lazy create initial notification policies
Refs #3752 - this change alone is a 4x increase in users-per-second
import speed.

This should be safe - I looked through as much relevant code as I
could find, and it all is already defensive against policies not
being set up yet.  In fact, when you initialize a blank db, the
initial user doesn't have policies set up, and they work just fine.

Change-Id: Id0e449ad0d588e83993bf83ea5536767c9166789
Reviewed-on: https://gerrit.instructure.com/3514
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Whitmer <brian@instructure.com>
2011-05-09 15:47:50 -06:00
Bracken Mosbacker 35deefea7d don't try to mass-assign send_scores_in_emails
refs #4479

Change-Id: Idb7827429a10024b6261e3d93a7c7c43b3556f28
Reviewed-on: https://gerrit.instructure.com/3498
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Whitmer <brian@instructure.com>
2011-05-05 14:32:45 -06:00
Brian Whitmer e8c3410404 opt-in for grades in emails
Students can now opt-in to receiving actual scores
in email/sms/facebook notifications about homework
grades.  This ability can be manually disabled at
the root account level if necessary.

fixes #4479

Change-Id: I1b769bef140719578fa345ca519999a2834b00f8
Reviewed-on: https://gerrit.instructure.com/3473
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-05-04 22:57:14 -06:00
Brian Whitmer 8b8173dcc9 Initial commit.
closes #6988138
2011-01-31 18:57:29 -07:00