use of sonia.scm.user.DisplayUser in project scm-review-plugin by scm-manager.
the class MentionMapper method extractMentionsFromComment.
public Set<String> extractMentionsFromComment(String comment) {
Set<String> mentions = new HashSet<>();
Matcher matcher = mentionPattern.matcher(comment);
while (matcher.find()) {
String matchingId = matcher.group(1);
Optional<DisplayUser> displayUser = userDisplayManager.get(matchingId);
displayUser.ifPresent(user -> mentions.add(user.getId()));
}
return mentions;
}
use of sonia.scm.user.DisplayUser in project scm-review-plugin by scm-manager.
the class MentionMapper method parseMentionsUserIdsToDisplayNames.
public BasicComment parseMentionsUserIdsToDisplayNames(BasicComment rootComment) {
BasicComment comment = rootComment.clone();
for (String mentionUserId : rootComment.getMentionUserIds()) {
Optional<DisplayUser> user = userDisplayManager.get(mentionUserId);
user.ifPresent(displayUser -> comment.setComment(comment.getComment().replaceAll("\\[" + mentionUserId + "]", displayUser.getDisplayName())));
}
return comment;
}
use of sonia.scm.user.DisplayUser in project scm-review-plugin by scm-manager.
the class HitEnricher method appendEmbeddedUserForAuthor.
private void appendEmbeddedUserForAuthor(HalAppender appender, Hit hit) {
Hit.Field author = hit.getFields().get("author");
Optional<DisplayUser> displayUser = userDisplayManager.get(((Hit.ValueField) author).getValue().toString());
if (displayUser.isPresent()) {
DisplayUser user = displayUser.get();
appender.appendEmbedded("user", new DisplayedUserDto(user.getId(), user.getDisplayName(), user.getMail()));
}
}
use of sonia.scm.user.DisplayUser in project scm-review-plugin by scm-manager.
the class MentionMapperTest method shouldAppendMultipleMentionsForMentionedUser.
@Test
void shouldAppendMultipleMentionsForMentionedUser() {
DisplayUser user1 = setupExistingUserMock("dent", "Arthur Dent", "dent@hitchhiker.org");
DisplayUser user2 = setupExistingUserMock("_anonymous", "SCM Anonymous", "anonymous@hitchhiker.org");
Set<String> userIds = ImmutableSet.of("dent", "_anonymous");
Set<DisplayUser> mentions = mentionMapper.mapMentions(userIds);
assertThat(mentions).hasSize(2);
assertThat(mentions).contains(user1);
assertThat(mentions).contains(user2);
}
use of sonia.scm.user.DisplayUser in project scm-review-plugin by scm-manager.
the class MergeResource method getMergeStrategyInfo.
@GET
@Path("{namespace}/{name}/{pullRequestId}/merge-strategy-info")
@Produces(PullRequestMediaType.MERGE_STRATEGY_INFO)
@Operation(summary = "Get commit message information", description = "Returns commit message information for the given merge strategy", tags = "Pull Request")
@ApiResponse(responseCode = "200", description = "commit message was created", content = @Content(schema = @Schema(implementation = MergeStrategyInfoDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public MergeStrategyInfoDto getMergeStrategyInfo(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @QueryParam("strategy") MergeStrategy strategy) {
MergeService.CommitDefaults commitDefaults = service.createCommitDefaults(new NamespaceAndName(namespace, name), pullRequestId, strategy);
DisplayUser commitAuthor = commitDefaults.getCommitAuthor();
return new MergeStrategyInfoDto(service.isCommitMessageDisabled(strategy), commitDefaults.getCommitMessage(), service.createMergeCommitMessageHint(strategy), renderCommitAuthorIfPresent(commitAuthor));
}
Aggregations