{"action":"closed","issue":{"url":"https://api.github.com/repos/BrilliantChemistry/NotifyOn/issues/18","repository_url":"https://api.github.com/repos/BrilliantChemistry/NotifyOn","labels_url":"https://api.github.com/repos/BrilliantChemistry/NotifyOn/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/BrilliantChemistry/NotifyOn/issues/18/comments","events_url":"https://api.github.com/repos/BrilliantChemistry/NotifyOn/issues/18/events","html_url":"https://github.com/BrilliantChemistry/NotifyOn/issues/18","id":174031813,"number":18,"title":"Support updating previous notifications instead of creating new","user":{"login":"seancdavis","id":5245089,"avatar_url":"https://avatars.githubusercontent.com/u/5245089?v=3","gravatar_id":"","url":"https://api.github.com/users/seancdavis","html_url":"https://github.com/seancdavis","followers_url":"https://api.github.com/users/seancdavis/followers","following_url":"https://api.github.com/users/seancdavis/following{/other_user}","gists_url":"https://api.github.com/users/seancdavis/gists{/gist_id}","starred_url":"https://api.github.com/users/seancdavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seancdavis/subscriptions","organizations_url":"https://api.github.com/users/seancdavis/orgs","repos_url":"https://api.github.com/users/seancdavis/repos","events_url":"https://api.github.com/users/seancdavis/events{/privacy}","received_events_url":"https://api.github.com/users/seancdavis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BrilliantChemistry/NotifyOn/labels/enhancement","name":"enhancement","color":"5EBEFF"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-30T14:18:34Z","updated_at":"2016-10-25T14:17:10Z","closed_at":"2016-10-25T14:17:10Z","body":"Add an option that would let you take the most recent notification matching a given set of conditions and update it as needed.\r\n\r\nThink of our common message example. We'll want to take the most recent notification from a specific sender to a specific recipient and update it instead of creating a new notification for every single message.\r\n\r\nBut it gets more complex than that. Say you wrap messages in a chat. Then you need a context by which you grab the most recent notification. However, it'd be nice if these were recipes baked into NotifyOn and not requiring another model method.\r\n\r\nHere's the proposed syntax:\r\n\r\n```ruby\r\nnotify_on # ...\r\n  :update => { :strategy => :sender, :scope => :chat }\r\n```\r\n\r\n`:strategy` will look for notifications matching the recipient, the _class_ (or _type_) of the trigger, and the strategy. Let's start by only supporting `:sender`.\r\n\r\n`:scope` will be an optional way to narrow/customize the strategy, where we say the results from the strategy must filter through scope as `new_trigger.send(scope) == old_notification.send(scope)`. We have to be careful in avoiding N+1 problems here.\r\n\r\nWe take the most recently updated result, or we create a new record.\r\n\r\nIf we find an existing record, it gets marked as unread, and the trigger and link get updated.\r\n\r\nWe send Pusher or email notifications following _the original_ options, as the options are not updated."}}
{"actor":{"display_login":"seancdavis"}}