Skip to content

Commit

Permalink
SONAR-4824 support branches when filtering recipients on their perms
Browse files Browse the repository at this point in the history
by querying permissions in DB with component key rather than component uuid
as computing the target branch's key from the branch's key is easy
  • Loading branch information
sns-seb committed Oct 4, 2017
1 parent aa39b79 commit 1b98f49
Show file tree
Hide file tree
Showing 34 changed files with 164 additions and 123 deletions.
Expand Up @@ -177,10 +177,10 @@ public List<String> selectGlobalAdministratorLogins(DbSession dbSession) {
return mapper(dbSession).selectLoginsWithGlobalPermission(ADMINISTER.getKey()); return mapper(dbSession).selectLoginsWithGlobalPermission(ADMINISTER.getKey());
} }


public Set<String> keepAuthorizedLoginsOnProject(DbSession dbSession, Set<String> logins, String projectUuid, String permission) { public Set<String> keepAuthorizedLoginsOnProject(DbSession dbSession, Set<String> logins, String projectKey, String permission) {
return executeLargeInputsIntoSet( return executeLargeInputsIntoSet(
logins, logins,
partitionOfLogins -> mapper(dbSession).keepAuthorizedLoginsOnProject(partitionOfLogins, projectUuid, permission), partitionOfLogins -> mapper(dbSession).keepAuthorizedLoginsOnProject(partitionOfLogins, projectKey, permission),
partitionSize -> partitionSize / 3); partitionSize -> partitionSize / 3);
} }


Expand Down
Expand Up @@ -63,7 +63,7 @@ int countUsersWithGlobalPermissionExcludingUserPermission(@Param("organizationUu


List<String> selectQualityProfileAdministratorLogins(@Param("permission") String permission); List<String> selectQualityProfileAdministratorLogins(@Param("permission") String permission);


Set<String> keepAuthorizedLoginsOnProject(@Param("logins") List<String> logins, @Param("projectUuid") String projectUuid, @Param("permission") String permission); Set<String> keepAuthorizedLoginsOnProject(@Param("logins") List<String> logins, @Param("projectKey") String projectKey, @Param("permission") String permission);


List<String> selectLoginsWithGlobalPermission(@Param("permission") String permission); List<String> selectLoginsWithGlobalPermission(@Param("permission") String permission);
} }
Expand Up @@ -66,9 +66,9 @@ public PropertiesDao(MyBatis mybatis, System2 system2) {
* *
* @return the list of Subscriber (maybe be empty - obviously) * @return the list of Subscriber (maybe be empty - obviously)
*/ */
public Set<Subscriber> findUsersForNotification(String notificationDispatcherKey, String notificationChannelKey, @Nullable String projectUuid) { public Set<Subscriber> findUsersForNotification(String notificationDispatcherKey, String notificationChannelKey, @Nullable String projectKey) {
try (DbSession session = mybatis.openSession(false)) { try (DbSession session = mybatis.openSession(false)) {
return getMapper(session).findUsersForNotification(NOTIFICATION_PREFIX + notificationDispatcherKey + "." + notificationChannelKey, projectUuid); return getMapper(session).findUsersForNotification(NOTIFICATION_PREFIX + notificationDispatcherKey + "." + notificationChannelKey, projectKey);
} }
} }


Expand Down
Expand Up @@ -26,7 +26,7 @@


public interface PropertiesMapper { public interface PropertiesMapper {


Set<Subscriber> findUsersForNotification(@Param("notifKey") String notificationKey, @Nullable @Param("projectUuid") String projectUuid); Set<Subscriber> findUsersForNotification(@Param("notifKey") String notificationKey, @Nullable @Param("projectKey") String projectKey);


List<PropertyDto> selectGlobalProperties(); List<PropertyDto> selectGlobalProperties();


Expand Down
Expand Up @@ -401,7 +401,7 @@
SELECT u.login SELECT u.login
FROM users u FROM users u
INNER JOIN user_roles ur ON ur.user_id = u.id INNER JOIN user_roles ur ON ur.user_id = u.id
INNER JOIN projects p ON p.uuid = #{projectUuid,jdbcType=VARCHAR} INNER JOIN projects p ON p.kee = #{projectKey,jdbcType=VARCHAR}
WHERE WHERE
ur.organization_uuid = p.organization_uuid ur.organization_uuid = p.organization_uuid
AND ur.resource_id = p.id AND ur.resource_id = p.id
Expand All @@ -412,7 +412,7 @@


SELECT u.login SELECT u.login
FROM users u FROM users u
INNER JOIN projects p ON p.uuid = #{projectUuid,jdbcType=VARCHAR} INNER JOIN projects p ON p.kee = #{projectKey,jdbcType=VARCHAR}
INNER JOIN group_roles gr ON gr.organization_uuid = p.organization_uuid INNER JOIN group_roles gr ON gr.organization_uuid = p.organization_uuid
INNER JOIN groups_users gu ON gr.group_id = gu.group_id INNER JOIN groups_users gu ON gr.group_id = gu.group_id
WHERE WHERE
Expand All @@ -425,7 +425,7 @@


SELECT u.login SELECT u.login
FROM users u FROM users u
INNER JOIN projects p ON p.uuid = #{projectUuid,jdbcType=VARCHAR} INNER JOIN projects p ON p.kee = #{projectKey,jdbcType=VARCHAR}
WHERE WHERE
p.private = ${_false} p.private = ${_false}
AND u.login IN <foreach collection="logins" open="(" close=")" item="login" separator=",">#{login}</foreach> AND u.login IN <foreach collection="logins" open="(" close=")" item="login" separator=",">#{login}</foreach>
Expand Down
Expand Up @@ -22,7 +22,7 @@
${_false} as "global" ${_false} as "global"
FROM FROM
users u users u
INNER JOIN projects c on c.uuid = #{projectUuid,jdbcType=VARCHAR} INNER JOIN projects c on c.kee = #{projectKey,jdbcType=VARCHAR}
INNER JOIN properties p ON p.user_id = u.id INNER JOIN properties p ON p.user_id = u.id
WHERE WHERE
p.prop_key = #{notifKey,jdbcType=VARCHAR} p.prop_key = #{notifKey,jdbcType=VARCHAR}
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.sonar.core.util.stream.MoreCollectors; import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbSession; import org.sonar.db.DbSession;
import org.sonar.db.DbTester; import org.sonar.db.DbTester;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentDto;
import org.sonar.db.organization.OrganizationDto; import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.GroupDto; import org.sonar.db.user.GroupDto;
Expand All @@ -61,6 +62,7 @@ public class AuthorizationDaoTest {
@Rule @Rule
public DbTester db = DbTester.create(System2.INSTANCE); public DbTester db = DbTester.create(System2.INSTANCE);


private final Random random = new Random();
private DbSession dbSession = db.getSession(); private DbSession dbSession = db.getSession();
private AuthorizationDao underTest = new AuthorizationDao(); private AuthorizationDao underTest = new AuthorizationDao();
private OrganizationDto organization; private OrganizationDto organization;
Expand All @@ -70,23 +72,23 @@ public class AuthorizationDaoTest {
private Set<Long> randomPublicProjectIds; private Set<Long> randomPublicProjectIds;
private Set<Long> randomPrivateProjectIds; private Set<Long> randomPrivateProjectIds;
private Set<Integer> randomExistingUserIds; private Set<Integer> randomExistingUserIds;
private String randomPermission = "p" + new Random().nextInt(); private String randomPermission = "p" + random.nextInt();


@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
organization = db.organizations().insert(); organization = db.organizations().insert();
user = db.users().insertUser(); user = db.users().insertUser();
group1 = db.users().insertGroup(organization, "group1"); group1 = db.users().insertGroup(organization, "group1");
group2 = db.users().insertGroup(organization, "group2"); group2 = db.users().insertGroup(organization, "group2");
randomExistingUserIds = IntStream.range(0, 1 + Math.abs(new Random().nextInt(5))) randomExistingUserIds = IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.map(i -> db.users().insertUser().getId()) .map(i -> db.users().insertUser().getId())
.boxed() .boxed()
.collect(MoreCollectors.toSet()); .collect(MoreCollectors.toSet());
randomPublicProjectIds = IntStream.range(0, 1 + Math.abs(new Random().nextInt(5))) randomPublicProjectIds = IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.mapToLong(i -> db.components().insertPublicProject(organization).getId()) .mapToLong(i -> db.components().insertPublicProject(organization).getId())
.boxed() .boxed()
.collect(MoreCollectors.toSet()); .collect(MoreCollectors.toSet());
randomPrivateProjectIds = IntStream.range(0, 1 + Math.abs(new Random().nextInt(5))) randomPrivateProjectIds = IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.mapToLong(i -> db.components().insertPrivateProject(organization).getId()) .mapToLong(i -> db.components().insertPrivateProject(organization).getId())
.boxed() .boxed()
.collect(MoreCollectors.toSet()); .collect(MoreCollectors.toSet());
Expand Down Expand Up @@ -239,7 +241,7 @@ public void keepAuthorizedProjectIds_returns_empty_for_user_if_project_set_is_em


@Test @Test
public void keepAuthorizedProjectIds_returns_empty_for_group_AnyOne_for_non_existent_projects() { public void keepAuthorizedProjectIds_returns_empty_for_group_AnyOne_for_non_existent_projects() {
Set<Long> randomNonProjectsSet = IntStream.range(0, 1 + Math.abs(new Random().nextInt(5))) Set<Long> randomNonProjectsSet = IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.mapToLong(i -> 3_562 + i) .mapToLong(i -> 3_562 + i)
.boxed() .boxed()
.collect(MoreCollectors.toSet()); .collect(MoreCollectors.toSet());
Expand All @@ -250,7 +252,7 @@ public void keepAuthorizedProjectIds_returns_empty_for_group_AnyOne_for_non_exis


@Test @Test
public void keepAuthorizedProjectIds_returns_empty_for_user_for_non_existent_projects() { public void keepAuthorizedProjectIds_returns_empty_for_user_for_non_existent_projects() {
Set<Long> randomNonProjectsSet = IntStream.range(0, 1 + Math.abs(new Random().nextInt(5))) Set<Long> randomNonProjectsSet = IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.mapToLong(i -> 9_666 + i) .mapToLong(i -> 9_666 + i)
.boxed() .boxed()
.collect(MoreCollectors.toSet()); .collect(MoreCollectors.toSet());
Expand Down Expand Up @@ -513,8 +515,8 @@ public void keepAuthorizedUsersForRoleAndProject_returns_empty_if_user_set_is_em


@Test @Test
public void keepAuthorizedUsersForRoleAndProject_returns_empty_for_non_existent_users() { public void keepAuthorizedUsersForRoleAndProject_returns_empty_for_non_existent_users() {
ComponentDto project = new Random().nextBoolean() ? db.components().insertPublicProject(organization) : db.components().insertPrivateProject(organization); ComponentDto project = random.nextBoolean() ? db.components().insertPublicProject(organization) : db.components().insertPrivateProject(organization);
Set<Integer> randomNonExistingUserIdsSet = IntStream.range(0, 1 + Math.abs(new Random().nextInt(5))) Set<Integer> randomNonExistingUserIdsSet = IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.map(i -> i + 1_990) .map(i -> i + 1_990)
.boxed() .boxed()
.collect(MoreCollectors.toSet()); .collect(MoreCollectors.toSet());
Expand Down Expand Up @@ -1044,11 +1046,11 @@ public void keepAuthorizedLoginsOnProject_return_correct_users_on_public_project
db.users().insertMember(adminGroup, admin2); db.users().insertMember(adminGroup, admin2);
db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project); db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project);


assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin()), project.uuid(), UserRole.USER)) assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin()), project.getKey(), UserRole.USER))
.containsOnly(user1.getLogin()); .containsOnly(user1.getLogin());
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin(), admin1.getLogin(), admin2.getLogin()), project.uuid(), UserRole.USER)) assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin(), admin1.getLogin(), admin2.getLogin()), project.getKey(), UserRole.USER))
.containsOnly(user1.getLogin(), admin1.getLogin(), admin2.getLogin()); .containsOnly(user1.getLogin(), admin1.getLogin(), admin2.getLogin());
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin(), admin1.getLogin(), admin2.getLogin()), project.uuid(), UserRole.ADMIN)) assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin(), admin1.getLogin(), admin2.getLogin()), project.getKey(), UserRole.ADMIN))
.containsOnly(admin1.getLogin(), admin2.getLogin()); .containsOnly(admin1.getLogin(), admin2.getLogin());
} }


Expand Down Expand Up @@ -1080,17 +1082,60 @@ public void keepAuthorizedLoginsOnProject_return_correct_users_on_private_projec
// user without role // user without role
UserDto userWithNoRole = db.users().insertUser(); UserDto userWithNoRole = db.users().insertUser();


assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(userWithNoRole.getLogin()), project.uuid(), UserRole.USER)) assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(userWithNoRole.getLogin()), project.getKey(), UserRole.USER))
.isEmpty(); .isEmpty();
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin()), project.uuid(), UserRole.USER)) assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin()), project.getKey(), UserRole.USER))
.containsOnly(user1.getLogin()); .containsOnly(user1.getLogin());


Set<String> allLogins = newHashSet(admin1.getLogin(), admin2.getLogin(), user1.getLogin(), user2.getLogin(), userWithNoRole.getLogin()); Set<String> allLogins = newHashSet(admin1.getLogin(), admin2.getLogin(), user1.getLogin(), user2.getLogin(), userWithNoRole.getLogin());


// Admin does not have the USER permission set // Admin does not have the USER permission set
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.uuid(), UserRole.USER)) assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.getKey(), UserRole.USER))
.containsOnly(user1.getLogin(), user2.getLogin()); .containsOnly(user1.getLogin(), user2.getLogin());
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.uuid(), UserRole.ADMIN)) assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.getKey(), UserRole.ADMIN))
.containsOnly(admin1.getLogin(), admin2.getLogin());
}

@Test
public void keepAuthorizedLoginsOnProject_return_correct_users_on_branch() {
ComponentDto project = db.components().insertPrivateProject(organization);
ComponentDto branch = db.components().insertProjectBranch(project, c -> c.setBranchType(random.nextBoolean() ? BranchType.SHORT : BranchType.LONG));

GroupDto userGroup = db.users().insertGroup(organization, "USERS");
GroupDto adminGroup = db.users().insertGroup(organization, "ADMIN");
db.users().insertProjectPermissionOnGroup(userGroup, UserRole.USER, project);
db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project);

// admin with "direct" ADMIN role
UserDto admin1 = db.users().insertUser();
db.users().insertProjectPermissionOnUser(admin1, UserRole.ADMIN, project);

// admin2 with ADMIN role through group
UserDto admin2 = db.users().insertUser();
db.users().insertMember(adminGroup, admin2);

// user1 with "direct" USER role
UserDto user1 = db.users().insertUser();
db.users().insertProjectPermissionOnUser(user1, UserRole.USER, project);

// user2 with USER role through group
UserDto user2 = db.users().insertUser();
db.users().insertMember(userGroup, user2);

// user without role
UserDto userWithNoRole = db.users().insertUser();

assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(userWithNoRole.getLogin()), branch.getKey(), UserRole.USER))
.isEmpty();
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin()), branch.getKey(), UserRole.USER))
.containsOnly(user1.getLogin());

Set<String> allLogins = newHashSet(admin1.getLogin(), admin2.getLogin(), user1.getLogin(), user2.getLogin(), userWithNoRole.getLogin());

// Admin does not have the USER permission set
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, branch.getKey(), UserRole.USER))
.containsOnly(user1.getLogin(), user2.getLogin());
assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, branch.getKey(), UserRole.ADMIN))
.containsOnly(admin1.getLogin(), admin2.getLogin()); .containsOnly(admin1.getLogin(), admin2.getLogin());
} }
} }
Expand Up @@ -101,10 +101,10 @@ public void shouldFindUsersForNotification() throws SQLException {
assertThat(underTest.findUsersForNotification("NewViolations", "Email", "uuid_78")) assertThat(underTest.findUsersForNotification("NewViolations", "Email", "uuid_78"))
.isEmpty(); .isEmpty();


assertThat(underTest.findUsersForNotification("NewViolations", "Email", project1.uuid())) assertThat(underTest.findUsersForNotification("NewViolations", "Email", project1.getKey()))
.containsOnly(new Subscriber("user2", false)); .containsOnly(new Subscriber("user2", false));


assertThat(underTest.findUsersForNotification("NewViolations", "Email", project2.uuid())) assertThat(underTest.findUsersForNotification("NewViolations", "Email", project2.getKey()))
.isEmpty(); .isEmpty();


assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", null)) assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", null))
Expand All @@ -113,10 +113,10 @@ public void shouldFindUsersForNotification() throws SQLException {
assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", "uuid_78")) assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", "uuid_78"))
.containsOnly(new Subscriber("user3", true)); .containsOnly(new Subscriber("user3", true));


assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", project1.uuid())) assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", project1.getKey()))
.containsOnly(new Subscriber("user2", false), new Subscriber("user3", true)); .containsOnly(new Subscriber("user2", false), new Subscriber("user3", true));


assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", project2.uuid())) assertThat(underTest.findUsersForNotification("NewViolations", "Twitter", project2.getKey()))
.containsOnly(new Subscriber("user1", false), new Subscriber("user3", true), new Subscriber("user3", false)); .containsOnly(new Subscriber("user1", false), new Subscriber("user3", true), new Subscriber("user3", false));
} }


Expand Down
Expand Up @@ -55,9 +55,9 @@ public String getKey() {


@Override @Override
public void dispatch(Notification notification, Context context) { public void dispatch(Notification notification, Context context) {
String projectUuid = notification.getFieldValue("project.uuid"); String projectKey = notification.getFieldValue("project.key");
Multimap<String, NotificationChannel> subscribedRecipients = manager.findSubscribedRecipientsForDispatcher( Multimap<String, NotificationChannel> subscribedRecipients = manager
this, projectUuid, REQUIRED_SUBSCRIBER_PERMISSIONS); .findSubscribedRecipientsForDispatcher(this, projectKey, REQUIRED_SUBSCRIBER_PERMISSIONS);


for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) { for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) {
String userLogin = channelsByRecipients.getKey(); String userLogin = channelsByRecipients.getKey();
Expand Down
Expand Up @@ -127,7 +127,6 @@ private void notifyUsers(Component project, String label, QualityGateStatus rawS
.setDefaultMessage(String.format("Alert on %s: %s", project.getName(), label)) .setDefaultMessage(String.format("Alert on %s: %s", project.getName(), label))
.setFieldValue("projectName", project.getName()) .setFieldValue("projectName", project.getName())
.setFieldValue("projectKey", project.getPublicKey()) .setFieldValue("projectKey", project.getPublicKey())
.setFieldValue("projectUuid", project.getUuid())
.setFieldValue("projectVersion", project.getReportAttributes().getVersion()) .setFieldValue("projectVersion", project.getReportAttributes().getVersion())
.setFieldValue("alertName", label) .setFieldValue("alertName", label)
.setFieldValue("alertText", rawStatus.getText()) .setFieldValue("alertText", rawStatus.getText())
Expand Down
Expand Up @@ -127,7 +127,7 @@ private void sendIssueChangeNotification(DefaultIssue issue, Component project)
IssueChangeNotification changeNotification = new IssueChangeNotification(); IssueChangeNotification changeNotification = new IssueChangeNotification();
changeNotification.setRuleName(rules.getByKey(issue.ruleKey()).getName()); changeNotification.setRuleName(rules.getByKey(issue.ruleKey()).getName());
changeNotification.setIssue(issue); changeNotification.setIssue(issue);
changeNotification.setProject(project.getPublicKey(), project.getName(), getBranchName(), project.getUuid()); changeNotification.setProject(project.getPublicKey(), project.getName(), getBranchName());
getComponentKey(issue).ifPresent(c -> changeNotification.setComponent(c.getPublicKey(), c.getName())); getComponentKey(issue).ifPresent(c -> changeNotification.setComponent(c.getPublicKey(), c.getName()));
service.deliver(changeNotification); service.deliver(changeNotification);
} }
Expand All @@ -136,7 +136,7 @@ private void sendNewIssuesNotification(NewIssuesStatistics statistics, Component
NewIssuesStatistics.Stats globalStatistics = statistics.globalStatistics(); NewIssuesStatistics.Stats globalStatistics = statistics.globalStatistics();
NewIssuesNotification notification = newIssuesNotificationFactory NewIssuesNotification notification = newIssuesNotificationFactory
.newNewIssuesNotication() .newNewIssuesNotication()
.setProject(project.getPublicKey(), project.getUuid(), project.getName(), getBranchName()) .setProject(project.getPublicKey(), project.getName(), getBranchName())
.setProjectVersion(project.getReportAttributes().getVersion()) .setProjectVersion(project.getReportAttributes().getVersion())
.setAnalysisDate(new Date(analysisDate)) .setAnalysisDate(new Date(analysisDate))
.setStatistics(project.getName(), globalStatistics) .setStatistics(project.getName(), globalStatistics)
Expand All @@ -155,7 +155,7 @@ private void sendNewIssuesNotificationToAssignees(NewIssuesStatistics statistics
.newMyNewIssuesNotification() .newMyNewIssuesNotification()
.setAssignee(assignee); .setAssignee(assignee);
myNewIssuesNotification myNewIssuesNotification
.setProject(project.getPublicKey(), project.getUuid(), project.getName(), getBranchName()) .setProject(project.getPublicKey(), project.getName(), getBranchName())
.setProjectVersion(project.getReportAttributes().getVersion()) .setProjectVersion(project.getReportAttributes().getVersion())
.setAnalysisDate(new Date(analysisDate)) .setAnalysisDate(new Date(analysisDate))
.setStatistics(project.getName(), assigneeStatistics) .setStatistics(project.getName(), assigneeStatistics)
Expand Down
Expand Up @@ -58,10 +58,10 @@ public static NotificationDispatcherMetadata newMetadata() {


@Override @Override
public void dispatch(Notification notification, Context context) { public void dispatch(Notification notification, Context context) {
String projectUuid = notification.getFieldValue("projectUuid"); String projectKey = notification.getFieldValue("projectKey");
if (projectUuid != null) { if (projectKey != null) {
Multimap<String, NotificationChannel> subscribedRecipients = notifications.findSubscribedRecipientsForDispatcher( Multimap<String, NotificationChannel> subscribedRecipients = notifications
this, projectUuid, ALL_MUST_HAVE_ROLE_USER); .findSubscribedRecipientsForDispatcher(this, projectKey, ALL_MUST_HAVE_ROLE_USER);


for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) { for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) {
String userLogin = channelsByRecipients.getKey(); String userLogin = channelsByRecipients.getKey();
Expand Down
Expand Up @@ -51,7 +51,6 @@ public abstract class AbstractNewIssuesEmailTemplate extends EmailTemplate {
static final String FIELD_PROJECT_NAME = "projectName"; static final String FIELD_PROJECT_NAME = "projectName";
static final String FIELD_PROJECT_KEY = "projectKey"; static final String FIELD_PROJECT_KEY = "projectKey";
static final String FIELD_PROJECT_DATE = "projectDate"; static final String FIELD_PROJECT_DATE = "projectDate";
static final String FIELD_PROJECT_UUID = "projectUuid";
static final String FIELD_PROJECT_VERSION = "projectVersion"; static final String FIELD_PROJECT_VERSION = "projectVersion";
static final String FIELD_ASSIGNEE = "assignee"; static final String FIELD_ASSIGNEE = "assignee";
static final String FIELD_BRANCH = "branch"; static final String FIELD_BRANCH = "branch";
Expand Down
Expand Up @@ -59,9 +59,9 @@ public static NotificationDispatcherMetadata newMetadata() {


@Override @Override
public void dispatch(Notification notification, Context context) { public void dispatch(Notification notification, Context context) {
String projectUuid = notification.getFieldValue("projectUuid"); String projectKey = notification.getFieldValue("projectKey");
Multimap<String, NotificationChannel> subscribedRecipients = notificationManager.findSubscribedRecipientsForDispatcher( Multimap<String, NotificationChannel> subscribedRecipients = notificationManager
this, projectUuid, ALL_MUST_HAVE_ROLE_USER); .findSubscribedRecipientsForDispatcher(this, projectKey, ALL_MUST_HAVE_ROLE_USER);


// See available fields in the class IssueNotifications. // See available fields in the class IssueNotifications.


Expand Down

0 comments on commit 1b98f49

Please sign in to comment.