upload client name and server address as description
This commit is contained in:
@@ -6,6 +6,7 @@ import dev.photosync.core.config.NotificationKind;
|
||||
import dev.photosync.core.config.PhotoSyncConfig;
|
||||
import dev.photosync.core.upload.UploadEvent;
|
||||
import dev.photosync.mcapi.ClientBridge;
|
||||
import dev.photosync.mcapi.GameContext;
|
||||
import dev.photosync.mcapi.capture.ScreenshotBus;
|
||||
import dev.photosync.mcapi.lifecycle.QuitGuard;
|
||||
import dev.photosync.mcapi.render.RenderBridge;
|
||||
@@ -114,7 +115,29 @@ public final class PhotoSyncClient implements AutoCloseable {
|
||||
log.debug("Not queuing {}: no provider configured", shot.fileName());
|
||||
return;
|
||||
}
|
||||
core.queue().enqueue(shot, config.album());
|
||||
core.queue().enqueue(shot, config.album(), captureDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* One line for the upload's description: the window title -- which a
|
||||
* modpack replaces with its own name -- and the server being played on, or
|
||||
* the word for single player.
|
||||
*
|
||||
* <p>Snapshot at capture time, because the queue outlives the session: a
|
||||
* screenshot retried tomorrow should describe the moment it was taken, not
|
||||
* whatever server the player is on when the retry fires.
|
||||
*/
|
||||
private String captureDescription() {
|
||||
try {
|
||||
GameContext game = bridge.game();
|
||||
String where = game.serverAddress()
|
||||
.orElseGet(() -> chrome().translate("photosync.description.singleplayer"));
|
||||
return game.clientName() + " · " + where;
|
||||
} catch (RuntimeException e) {
|
||||
// A description that cannot be captured must not cost the upload.
|
||||
log.warn("Could not capture the screenshot context", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private void uploadChanged(UploadEvent event) {
|
||||
|
||||
@@ -114,6 +114,8 @@
|
||||
"photosync.notify.uploaded": "Uploaded %s",
|
||||
"photosync.notify.failed": "Upload failed: %s",
|
||||
|
||||
"photosync.description.singleplayer": "Singleplayer",
|
||||
|
||||
"photosync.provider.immich.name": "Immich",
|
||||
"photosync.provider.immich.endpoint": "Server URL",
|
||||
"photosync.provider.immich.endpoint.hint": "https://photos.example.com",
|
||||
|
||||
@@ -114,6 +114,8 @@
|
||||
"photosync.notify.uploaded": "已上传 %s",
|
||||
"photosync.notify.failed": "上传失败:%s",
|
||||
|
||||
"photosync.description.singleplayer": "单人",
|
||||
|
||||
"photosync.provider.immich.name": "Immich",
|
||||
"photosync.provider.immich.endpoint": "服务器地址",
|
||||
"photosync.provider.immich.endpoint.hint": "https://photos.example.com",
|
||||
|
||||
Reference in New Issue
Block a user