Skip to content

Commit 3aae481

Browse files
committed
Merge branch 'develop' into feature-2645/feedback-request-add-ability-to-request-feedback-from-external-source
2 parents 9b93580 + 1fcfe3e commit 3aae481

32 files changed

+443
-485
lines changed

.github/workflows/gradle-build-production.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ jobs:
8282
--set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \
8383
--set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \
8484
--set-env-vars "WEB_ADDRESS=${{ env.TARGET_URL }}" \
85-
--set-env-vars "FROM_ADDRESS=kimberlinm@objectcomputing.com" \
85+
--set-env-vars "FROM_ADDRESS=no-reply@objectcomputing.com" \
8686
--set-env-vars "FROM_NAME=Check-Ins" \
8787
--set-env-vars "^@^MICRONAUT_ENVIRONMENTS=cloud,google,gcp" \
8888
--platform "managed" \
89-
--max-instances 5 \
89+
--max-instances 8 \
9090
--allow-unauthenticated

.github/workflows/gradle-deploy-develop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
--set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \
108108
--set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \
109109
--set-env-vars "WEB_ADDRESS=${{ env.TARGET_URL }}" \
110-
--set-env-vars "FROM_ADDRESS=kimberlinm@objectcomputing.com" \
110+
--set-env-vars "FROM_ADDRESS=no-reply@objectcomputing.com" \
111111
--set-env-vars "FROM_NAME=Check-Ins - DEVELOP" \
112112
--set-env-vars "^@^MICRONAUT_ENVIRONMENTS=dev,cloud,google,gcp" \
113113
--platform "managed" \

server/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
id "jacoco"
88
}
99

10-
version "0.8.1"
10+
version "0.8.5"
1111
group "com.objectcomputing.checkins"
1212

1313
repositories {

server/src/main/java/com/objectcomputing/checkins/notifications/email/MailJetSender.java

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ public void sendEmail(String fromName, String fromAddress, String subject, Strin
9090
return;
9191
}
9292

93-
List<JSONArray> emailBatches = getEmailBatches(recipients);
94-
List<JSONArray> failedBatches = new ArrayList<>();
9593
JSONObject sender = new JSONObject()
9694
.put("Email", fromAddress)
9795
.put("Name", fromName);
@@ -106,27 +104,33 @@ public void sendEmail(String fromName, String fromAddress, String subject, Strin
106104
final String localEmailFormat = modifiedEmailFormat;
107105
final String localContent = content;
108106

109-
emailBatches.forEach((recipientList) -> {
110-
MailjetRequest request = new MailjetRequest(Emailv31.resource)
111-
.property(Emailv31.MESSAGES, new JSONArray()
112-
.put(new JSONObject()
113-
.put(Emailv31.Message.FROM, sender)
114-
.put(Emailv31.Message.TO, new JSONArray().put(sender))
115-
.put(Emailv31.Message.BCC, recipientList)
116-
.put(Emailv31.Message.SUBJECT, subject)
117-
.put(localEmailFormat, localContent)));
107+
if (recipients.length == 1) {
108+
final JSONArray to = new JSONArray()
109+
.put(new JSONObject().put("Email", recipients[0]));
118110
try {
119-
MailjetResponse response = client.post(request);
120-
LOG.info("Mailjet response status: {}", response.getStatus());
121-
LOG.info("Mailjet response data: {}", response.getData());
111+
send(sender, to, null, subject, localEmailFormat, localContent);
122112
} catch (MailjetException e) {
123-
LOG.error("An unexpected error occurred while sending the upload notification: {}", e.getLocalizedMessage(), e);
124-
failedBatches.add(recipientList);
113+
throw new BadArgException("Failed to send email for " + to);
114+
}
115+
} else {
116+
List<JSONArray> emailBatches = getEmailBatches(recipients);
117+
List<JSONArray> failedBatches = new ArrayList<>();
118+
final JSONArray to =
119+
new JSONArray()
120+
.put(new JSONObject().put("Email", this.fromAddress));
121+
emailBatches.forEach((recipientList) -> {
122+
try {
123+
send(sender, to, recipientList,
124+
subject, localEmailFormat, localContent);
125+
} catch (MailjetException e) {
126+
LOG.error("An unexpected error occurred while sending the upload notification: {}", e.getLocalizedMessage(), e);
127+
failedBatches.add(recipientList);
128+
}
129+
});
130+
131+
if (!failedBatches.isEmpty()) {
132+
throw new BadArgException("Failed to send emails for " + failedBatches);
125133
}
126-
});
127-
128-
if (!failedBatches.isEmpty()) {
129-
throw new BadArgException("Failed to send emails for " + failedBatches);
130134
}
131135
}
132136

@@ -154,4 +158,22 @@ public void setEmailFormat(String format) {
154158
throw new BadArgException(String.format("Email format must be either HTMLPART, MJMLPART or TEXTPART, got %s", format));
155159
}
156160
}
161+
162+
private void send(JSONObject from, JSONArray to, JSONArray bcc,
163+
String subject, String emailFormat, String content) throws MailjetException {
164+
JSONObject values = new JSONObject()
165+
.put(Emailv31.Message.FROM, from)
166+
.put(Emailv31.Message.TO, to)
167+
.put(Emailv31.Message.SUBJECT, subject)
168+
.put(emailFormat, content);
169+
if (bcc != null) {
170+
values.put(Emailv31.Message.BCC, bcc);
171+
}
172+
173+
MailjetRequest request = new MailjetRequest(Emailv31.resource)
174+
.property(Emailv31.MESSAGES, new JSONArray().put(values));
175+
MailjetResponse response = client.post(request);
176+
LOG.info("Mailjet response status: {}", response.getStatus());
177+
LOG.info("Mailjet response data: {}", response.getData());
178+
}
157179
}

server/src/main/java/com/objectcomputing/checkins/services/guild/Guild.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,22 @@ public class Guild {
6464
@Schema(description = "Is the guild a community")
6565
private boolean community;
6666

67-
public Guild(String name, @Nullable String description, @Nullable String link, boolean community) {
68-
this(null, name, description, link, community);
67+
@NotNull
68+
@Column(name = "is_active")
69+
@Schema(description = "whether the guild is active")
70+
private boolean active = true;
71+
72+
public Guild(String name, @Nullable String description, @Nullable String link, boolean community, boolean active) {
73+
this(null, name, description, link, community, active);
6974
}
7075

71-
public Guild(UUID id, String name, @Nullable String description, @Nullable String link, boolean community) {
76+
public Guild(UUID id, String name, @Nullable String description, @Nullable String link, boolean community, boolean active) {
7277
this.id = id;
7378
this.name = name;
7479
this.description = description;
7580
this.link = link;
7681
this.community = community;
82+
this.active = active;
7783
}
7884

7985
@Override
@@ -85,13 +91,14 @@ public boolean equals(Object o) {
8591
Objects.equals(name, guild.name) &&
8692
Objects.equals(description, guild.description) &&
8793
Objects.equals(link, guild.link) &&
88-
Objects.equals(community, guild.community);
94+
Objects.equals(community, guild.community) &&
95+
Objects.equals(active, guild.active);
8996

9097
}
9198

9299
@Override
93100
public int hashCode() {
94-
return Objects.hash(id, name, description, link, community);
101+
return Objects.hash(id, name, description, link, community, active);
95102
}
96103

97104
@Override
@@ -102,6 +109,7 @@ public String toString() {
102109
", description='" + description + '\'' +
103110
", link='" + link +
104111
", community=" + community +
112+
", active=" + active +
105113
'}';
106114
}
107115
}

server/src/main/java/com/objectcomputing/checkins/services/guild/GuildCreateDTO.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ public class GuildCreateDTO {
3636
@Schema(description = "Is the guild a community")
3737
private boolean community;
3838

39-
public GuildCreateDTO(String name, @Nullable String description, @Nullable String link, boolean community) {
39+
@NotNull
40+
@Schema(description = "whether the guild is active")
41+
private boolean active;
42+
43+
public GuildCreateDTO(String name, @Nullable String description, @Nullable String link, boolean community, boolean active) {
4044
this.name = name;
4145
this.description = description;
4246
this.link =link;
4347
this.community = community;
48+
this.active = active;
4449
}
4550

4651
@Data

server/src/main/java/com/objectcomputing/checkins/services/guild/GuildRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface GuildRepository extends CrudRepository<Guild, UUID> {
2929
@Query(value = "SELECT t_.id, PGP_SYM_DECRYPT(cast(t_.name as bytea),'${aes.key}') as name, " +
3030
"PGP_SYM_DECRYPT(cast(description as bytea),'${aes.key}') as description, " +
3131
"PGP_SYM_DECRYPT(cast(link as bytea),'${aes.key}') as link, " +
32-
"t_.community as community " +
32+
"t_.community as community, is_active " +
3333
"FROM guild t_ " +
3434
"LEFT JOIN guild_member tm_ " +
3535
" ON t_.id = tm_.guildid " +

server/src/main/java/com/objectcomputing/checkins/services/guild/GuildResponseDTO.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ public class GuildResponseDTO {
4040
@Schema(description = "Is the guild a community")
4141
private boolean community;
4242

43-
public GuildResponseDTO(UUID id, String name, @Nullable String description, @Nullable String link, boolean community) {
43+
@NotNull
44+
@Schema(description = "whether the guild is active")
45+
private boolean active;
46+
47+
public GuildResponseDTO(UUID id, String name, @Nullable String description, @Nullable String link, boolean community, boolean active) {
4448
this.id = id;
4549
this.name = name;
4650
this.description = description;
4751
this.link = link;
4852
this.community = community;
53+
this.active = active;
4954
}
5055

5156
public List<GuildMemberResponseDTO> getGuildMembers() {

server/src/main/java/com/objectcomputing/checkins/services/guild/GuildServicesImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private Guild fromDTO(GuildUpdateDTO dto) {
252252
if (dto == null) {
253253
return null;
254254
}
255-
return new Guild(dto.getId(), dto.getName(), dto.getDescription(), dto.getLink(), dto.isCommunity());
255+
return new Guild(dto.getId(), dto.getName(), dto.getDescription(), dto.getLink(), dto.isCommunity(), dto.isActive());
256256
}
257257

258258
private GuildMember fromMemberDTO(GuildCreateDTO.GuildMemberCreateDTO memberDTO, UUID guildId) {
@@ -276,7 +276,7 @@ private GuildResponseDTO fromEntity(Guild entity, List<GuildMemberResponseDTO> m
276276
return null;
277277
}
278278
GuildResponseDTO dto = new GuildResponseDTO(entity.getId(), entity.getName(), entity.getDescription(),
279-
entity.getLink(), entity.isCommunity());
279+
entity.getLink(), entity.isCommunity(), entity.isActive());
280280
dto.setGuildMembers(memberEntities);
281281
return dto;
282282
}
@@ -285,7 +285,7 @@ private Guild fromDTO(GuildCreateDTO dto) {
285285
if (dto == null) {
286286
return null;
287287
}
288-
return new Guild(null, dto.getName(), dto.getDescription(), dto.getLink(), dto.isCommunity());
288+
return new Guild(null, dto.getName(), dto.getDescription(), dto.getLink(), dto.isCommunity(), dto.isActive());
289289
}
290290

291291
private GuildMemberResponseDTO fromMemberEntity(GuildMember guildMember, MemberProfile memberProfile) {

server/src/main/java/com/objectcomputing/checkins/services/guild/GuildUpdateDTO.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ public class GuildUpdateDTO {
3737
@Schema(description = "Is the guild a community")
3838
private boolean community;
3939

40-
public GuildUpdateDTO(UUID id, String name, @Nullable String description, @Nullable String link, boolean community) {
40+
@NotNull
41+
@Schema(description = "whether the guild is active")
42+
private boolean active;
43+
44+
public GuildUpdateDTO(UUID id, String name, @Nullable String description, @Nullable String link, boolean community, boolean active) {
4145
this.id = id;
4246
this.name = name;
4347
this.description = description;
4448
this.link = link;
4549
this.community = community;
50+
this.active = active;
4651
}
4752

48-
public GuildUpdateDTO(String id, String name, String description, @Nullable String link, boolean community) {
49-
this(nullSafeUUIDFromString(id), name, description, link, community);
53+
public GuildUpdateDTO(String id, String name, String description, @Nullable String link, boolean community, boolean active) {
54+
this(nullSafeUUIDFromString(id), name, description, link, community, active);
5055
}
5156

5257
public GuildUpdateDTO() {
@@ -75,4 +80,4 @@ public GuildMemberUpdateDTO(UUID id, UUID memberId, Boolean lead) {
7580
this.lead = lead;
7681
}
7782
}
78-
}
83+
}

0 commit comments

Comments
 (0)