Skip to content

Commit

Permalink
fix: inconsistencies with website social link (closes #1370)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Jul 7, 2024
1 parent 4f936e3 commit 79db463
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.papermc.hangar.controller.internal;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.papermc.hangar.HangarComponent;
import io.papermc.hangar.components.auth.service.CredentialsService;
import io.papermc.hangar.components.auth.service.TokenService;
Expand Down Expand Up @@ -78,7 +76,6 @@ public class HangarUserController extends HangarComponent {

private static final Set<String> ACCEPTED_SOCIAL_TYPES = Set.of("discord", "github", "twitter", "youtube", "website");

private final ObjectMapper mapper;
private final UsersApiService usersApiService;
private final UserService userService;
private final NotificationService notificationService;
Expand All @@ -93,8 +90,7 @@ public class HangarUserController extends HangarComponent {
private final ProjectViewsDAO projectViewsDAO;

@Autowired
public HangarUserController(final ObjectMapper mapper, final UsersApiService usersApiService, final UserService userService, final NotificationService notificationService, final ProjectRoleService projectRoleService, final OrganizationService organizationService, final OrganizationRoleService organizationRoleService, final ProjectInviteService projectInviteService, final OrganizationInviteService organizationInviteService, final TokenService tokenService, final AvatarService avatarService, final CredentialsService credentialsService, final ProjectViewsDAO projectViewsDAO) {
this.mapper = mapper;
public HangarUserController(final UsersApiService usersApiService, final UserService userService, final NotificationService notificationService, final ProjectRoleService projectRoleService, final OrganizationService organizationService, final OrganizationRoleService organizationRoleService, final ProjectInviteService projectInviteService, final OrganizationInviteService organizationInviteService, final TokenService tokenService, final AvatarService avatarService, final CredentialsService credentialsService, final ProjectViewsDAO projectViewsDAO) {
this.usersApiService = usersApiService;
this.userService = userService;
this.notificationService = notificationService;
Expand Down Expand Up @@ -257,6 +253,9 @@ public void saveProfileSettings(@PathVariable final String userName, @RequestBod
if (!ACCEPTED_SOCIAL_TYPES.contains(social[0])) {
throw new HangarApiException("Badly formatted request, social type " + social[0] + " is unknown!");
}
if ("website".equals(social[0]) && !social[1].matches(this.config.getUrlRegex())) {
throw new HangarApiException("Badly formatted request, website " + social[1] + " is not a valid url! (Did you add https://?)");
}
map.put(social[0], social[1]);
}
userTable.setSocials(new JSONB(map));
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/UserHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const canEditCurrentUser = computed<boolean>(() => {
>
<IconMdiYoutube class="mr-1 hover:text-slate-400" />
</a>
<a v-if="viewingUser.socials?.website" :href="`https://${viewingUser.socials.website}`" class="ml-1" rel="external nofollow" title="Website Link">
<a v-if="viewingUser.socials?.website" :href="viewingUser.socials.website" class="ml-1" rel="external nofollow" title="Website Link">
<IconMdiWeb class="mr-1 hover:text-slate-400" />
</a>
<Tooltip v-if="viewingUser.socials?.discord">
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"used": "Used",
"reveal": "Reveal",
"error": {
"invalidUrl": "Invalid URL format",
"invalidUrl": "Invalid URL format (did you forget the https://?)",
"nameEmpty": "Name cannot be empty",
"fieldEmpty": "This field is required to be set"
}
Expand Down Expand Up @@ -1193,12 +1193,12 @@
"minLength": "Minimum length is {min}",
"pattern": "{property} is invalid, '{model}' doesn't match pattern '{regex}'",
"noDuplicated": "Can only select each {property} once!",
"url": "Invalid URL format",
"url": "Invalid URL format (did you forget https://?)",
"maxFileSize": "File is too large, max size is 10mb",
"validProjectName": "Project name is already taken"
},
"fieldError": {
"url": "Invalid url value for {0}, got {1}"
"url": "Invalid url value for {0}, got {1} (did you forget https://?)"
},
"prompts": {
"confirm": "Got it!",
Expand Down

0 comments on commit 79db463

Please sign in to comment.