How to subscribe new user to notifications?

限于喜欢 提交于 2020-01-07 05:36:29

问题


I have set up SonarQube 5.2 installation, and I want to enable notifications for new users by default. What I mean is these checkboxes in user profile. I couldn't find an answer in the documentation, the available plugins, the Internet, if anybody had a similar question. What I have found so far is user properties in the SQ database:

sonar=# select * from properties where user_id=6;
 id |                          prop_key                           | resource_id | text_value | user_id 
----+-------------------------------------------------------------+-------------+------------+---------
 85 | favourite                                                   |        3260 |            |       6
 91 | notification.ChangesOnMyIssue.EmailNotificationChannel      |             | true       |       6
 92 | notification.NewFalsePositiveIssue.EmailNotificationChannel |             | true       |       6
 93 | notification.SQ-MyNewIssues.EmailNotificationChannel        |             | true       |       6
 94 | notification.NewIssues.EmailNotificationChannel             |             | true       |       6
 95 | notification.NewAlerts.EmailNotificationChannel             |             | true       |       6
(6 rows)

I have even searched through the source code, but haven't found how to set user properties on user registration. What is the best way to achieve that?


回答1:


The documentation has been updated to be specific on this case: no functionality is provided to subscribe another user to notifications. Each user must choose to receive notifications himself.




回答2:


While I understand wanting people to choose spam for themselves, our company needs to require developers to immediately remediate their security issues. Because of this, we require developers to get notifications so that they are aware of issues. There are simply too many of them to constantly "use the act of persuasion".

Here is the insert statement I've used to turn on "My New Issues" notification for all developers that don't already have the notification on:

INSERT INTO properties 
        (prop_key, 
         resource_id, 
         user_id, 
         is_empty, 
         text_value, 
         clob_value, 
         created_at)
SELECT 'notification.SQ-MyNewIssues.EmailNotificationChannel', 
       NULL, 
       u.id, 
       0, 
       'true', 
       NULL, 
       Unix_timestamp(Now()) 
FROM   users u 
       LEFT JOIN properties p 
              ON ( u.id = p.user_id 
                   AND 
       p.prop_key = 'notification.SQ-MyNewIssues.EmailNotificationChannel' ) 
WHERE  p.user_id IS NULL; 


来源:https://stackoverflow.com/questions/35157802/how-to-subscribe-new-user-to-notifications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!