mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] Support Asset Upload
This commit is contained in:
parent
0fb6102c29
commit
b635447eaf
7 changed files with 87 additions and 24 deletions
|
@ -0,0 +1,14 @@
|
|||
package pro.gravit.launchserver.auth.core.interfaces.provider;
|
||||
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launchserver.auth.Feature;
|
||||
import pro.gravit.launchserver.auth.core.User;
|
||||
|
||||
@Feature("assetupload")
|
||||
public interface AuthSupportAssetUpload {
|
||||
String getAssetUploadUrl(String name, User user);
|
||||
|
||||
default AuthRequestEvent.OAuthRequestEvent getAssetUploadToken(String name, User user) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
import pro.gravit.launchserver.socket.response.WebSocketServerResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.*;
|
||||
import pro.gravit.launchserver.socket.response.cabinet.GetAssetUploadInfoResponse;
|
||||
import pro.gravit.launchserver.socket.response.management.FeaturesResponse;
|
||||
import pro.gravit.launchserver.socket.response.management.GetPublicKeyResponse;
|
||||
import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername;
|
||||
|
@ -82,6 +83,7 @@ public static void registerResponses() {
|
|||
providers.register("additionalData", AdditionalDataResponse.class);
|
||||
providers.register("clientProfileKey", FetchClientProfileKeyResponse.class);
|
||||
providers.register("getPublicKey", GetPublicKeyResponse.class);
|
||||
providers.register("getAssetUploadUrl", GetAssetUploadInfoResponse.class);
|
||||
}
|
||||
|
||||
public static String getIPFromContext(ChannelHandlerContext ctx) {
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package pro.gravit.launchserver.socket.response.auth;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class RestoreSessionResponse extends SimpleResponse {
|
||||
@LauncherNetworkAPI
|
||||
public UUID session;
|
||||
public boolean needUserInfo;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "restoreSession";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
sendError("Legacy session system removed");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package pro.gravit.launchserver.socket.response.cabinet;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.events.request.GetAssetUploadInfoRequestEvent;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportAssetUpload;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
|
||||
public class GetAssetUploadInfoResponse extends SimpleResponse {
|
||||
public String name;
|
||||
@Override
|
||||
public String getType() {
|
||||
return "getAssetUploadUrl";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
if(!client.isAuth || client.auth == null || client.getUser() == null) {
|
||||
sendError("Access denied");
|
||||
return;
|
||||
}
|
||||
var support = client.auth.isSupport(AuthSupportAssetUpload.class);
|
||||
if(support == null) {
|
||||
sendError("Not supported");
|
||||
return;
|
||||
}
|
||||
sendResult(new GetAssetUploadInfoRequestEvent(support.getAssetUploadUrl(name, client.getUser()), support.getAssetUploadToken(name, client.getUser())));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package pro.gravit.launcher.events.request;
|
||||
|
||||
import pro.gravit.launcher.events.RequestEvent;
|
||||
|
||||
public class GetAssetUploadInfoRequestEvent extends RequestEvent {
|
||||
public String url;
|
||||
public AuthRequestEvent.OAuthRequestEvent token;
|
||||
|
||||
public GetAssetUploadInfoRequestEvent() {
|
||||
}
|
||||
|
||||
public GetAssetUploadInfoRequestEvent(String url, AuthRequestEvent.OAuthRequestEvent token) {
|
||||
this.url = url;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "getAssetUploadUrl";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package pro.gravit.launcher.request.cabinet;
|
||||
|
||||
import pro.gravit.launcher.events.request.GetAssetUploadInfoRequestEvent;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
|
||||
public class GetAssetUploadInfo extends Request<GetAssetUploadInfoRequestEvent> {
|
||||
public String name;
|
||||
|
||||
public GetAssetUploadInfo() {
|
||||
}
|
||||
|
||||
public GetAssetUploadInfo(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "getAssetUploadUrl";
|
||||
}
|
||||
}
|
|
@ -111,6 +111,7 @@ public void registerResults() {
|
|||
results.register("additionalData", AdditionalDataRequestEvent.class);
|
||||
results.register("clientProfileKey", FetchClientProfileKeyRequestEvent.class);
|
||||
results.register("getPublicKey", GetPublicKeyRequestEvent.class);
|
||||
results.register("getAssetUploadUrl", GetAssetUploadInfoRequestEvent.class);
|
||||
resultsRegistered = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue