diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Appsmith.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Appsmith.java index fe8d85163c..9d2ecc71b0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Appsmith.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Appsmith.java @@ -2,4 +2,6 @@ package com.appsmith.server.constants; public class Appsmith { public final static String APPSMITH_REGISTERED = "appsmith_registered"; + // We default the origin header to the production deployment of the client's URL + public static final String DEFAULT_ORIGIN_HEADER = "https://app.appsmith.com"; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/CommentController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/CommentController.java index 8b07163ba1..0bd16ae693 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/CommentController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/CommentController.java @@ -49,7 +49,7 @@ public class CommentController extends BaseController> createThread(@Valid @RequestBody CommentThread resource, - @RequestHeader(name = "Origin") String originHeader) { + @RequestHeader(name = "Origin", required = false) String originHeader) { log.debug("Going to create resource {}", resource.getClass().getName()); return service.createThread(resource, originHeader) .map(created -> new ResponseDTO<>(HttpStatus.CREATED.value(), created, null)); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/CommentThread.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/CommentThread.java index faaec3eee3..4ca57d8d3a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/CommentThread.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/CommentThread.java @@ -54,8 +54,8 @@ public class CommentThread extends AbstractCommentDomain { @Data public static class Position { - Float top; - Float left; + Integer top; + Integer left; Float topPercent; Float leftPercent; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/RedirectHelper.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/RedirectHelper.java index 36d960405b..7413c13fd5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/RedirectHelper.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/RedirectHelper.java @@ -1,5 +1,6 @@ package com.appsmith.server.helpers; +import com.appsmith.server.constants.Appsmith; import com.appsmith.server.constants.Security; import com.appsmith.server.domains.ApplicationPage; import com.appsmith.server.services.ApplicationService; @@ -22,7 +23,6 @@ public class RedirectHelper { public static final String DEFAULT_REDIRECT_URL = "/applications"; public static final String SIGNUP_SUCCESS_URL = "/signup-success"; - public static final String DEFAULT_REDIRECT_ORIGIN = "https://app.appsmith.com"; private static final String REDIRECT_URL_HEADER = "X-Redirect-Url"; private static final String REDIRECT_URL_QUERY_PARAM = "redirectUrl"; private static final String FORK_APP_ID_QUERY_PARAM = "appId"; @@ -135,7 +135,7 @@ public class RedirectHelper { */ public String getRedirectDomain(HttpHeaders httpHeaders) { // This is the failsafe for when nothing could be identified - String redirectOrigin = DEFAULT_REDIRECT_ORIGIN; + String redirectOrigin = Appsmith.DEFAULT_ORIGIN_HEADER; if (!StringUtils.isEmpty(httpHeaders.getOrigin())) { // For PUT/POST requests or CORS? diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CommentServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CommentServiceImpl.java index 69c6800e95..6353924e40 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CommentServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CommentServiceImpl.java @@ -384,12 +384,13 @@ public class CommentServiceImpl extends BaseService i private static final String INVITE_USER_CLIENT_URL_FORMAT = "%s/user/signup?email=%s"; private static final String INVITE_USER_EMAIL_TEMPLATE = "email/inviteUserCreatorTemplate.html"; private static final String USER_ADDED_TO_ORGANIZATION_EMAIL_TEMPLATE = "email/inviteExistingUserToOrganizationTemplate.html"; - // We default the origin header to the production deployment of the client's URL - private static final String DEFAULT_ORIGIN_HEADER = "https://app.appsmith.com"; @Autowired public UserServiceImpl(Scheduler scheduler, @@ -421,7 +420,7 @@ public class UserServiceImpl extends BaseService i if (originHeader == null || originHeader.isBlank()) { // Default to the production link - originHeader = DEFAULT_ORIGIN_HEADER; + originHeader = Appsmith.DEFAULT_ORIGIN_HEADER; } final String finalOriginHeader = originHeader; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/EmailEventHandler.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/EmailEventHandler.java index e99c8566b9..18bf016961 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/EmailEventHandler.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/EmailEventHandler.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.Set; import static com.appsmith.server.acl.AclPermission.MANAGE_APPLICATIONS; +import static com.appsmith.server.constants.Appsmith.DEFAULT_ORIGIN_HEADER; @Component @RequiredArgsConstructor @@ -115,8 +116,13 @@ public class EmailEventHandler { if (Boolean.FALSE.equals(canManageApplication)) { // user has no permission to manage application urlPostfix = ""; } + + String baseUrl = originHeader; + if(StringUtils.isEmpty(originHeader)) { + baseUrl = DEFAULT_ORIGIN_HEADER; + } return String.format("%s/applications/%s/pages/%s%s?commentThreadId=%s&isCommentMode=true", - originHeader, application.getId(), pageId, urlPostfix, threadId + baseUrl, application.getId(), pageId, urlPostfix, threadId ); }