Move sticker creator API to chat service

This commit is contained in:
Fedor Indutny
2024-05-15 15:26:37 -07:00
committed by GitHub
parent a1e090d1f1
commit 31cbb89b0d
21 changed files with 124 additions and 587 deletions

View File

@@ -120,8 +120,6 @@ import { parseSignalRoute } from '../ts/util/signalRoutes';
import * as dns from '../ts/util/dns';
import { ZoomFactorService } from '../ts/services/ZoomFactorService';
const STICKER_CREATOR_PARTITION = 'sticker-creator';
const animationSettings = systemPreferences.getAnimationSettings();
if (OS.isMacOS()) {
@@ -1000,21 +998,24 @@ ipc.handle('database-ready', async () => {
getLogger().info('sending `database-ready`');
});
ipc.handle('get-art-creator-auth', () => {
const { promise, resolve } = explodePromise<unknown>();
strictAssert(mainWindow, 'Main window did not exist');
ipc.handle(
'art-creator:uploadStickerPack',
(_event: Electron.Event, data: unknown) => {
const { promise, resolve } = explodePromise<unknown>();
strictAssert(mainWindow, 'Main window did not exist');
mainWindow.webContents.send('open-art-creator');
mainWindow.webContents.send('art-creator:uploadStickerPack', data);
ipc.handleOnce('open-art-creator', (_event, { username, password }) => {
resolve({
baseUrl: config.get<string>('artCreatorUrl'),
username,
password,
ipc.once('art-creator:uploadStickerPack:done', (_doneEvent, response) => {
resolve(response);
});
});
return promise;
return promise;
}
);
ipc.on('art-creator:onUploadProgress', () => {
stickerCreatorWindow?.webContents.send('art-creator:onUploadProgress');
});
ipc.on('show-window', () => {
@@ -1735,19 +1736,15 @@ app.on('ready', async () => {
realpath(app.getAppPath()),
]);
const webSession = session.fromPartition(STICKER_CREATOR_PARTITION);
updateDefaultSession(session.defaultSession);
for (const s of [session.defaultSession, webSession]) {
updateDefaultSession(s);
if (getEnvironment() !== Environment.Test) {
installFileHandler({
session: s,
userDataPath,
installPath,
isWindows: OS.isWindows(),
});
}
if (getEnvironment() !== Environment.Test) {
installFileHandler({
session: session.defaultSession,
userDataPath,
installPath,
isWindows: OS.isWindows(),
});
}
installWebHandler({
@@ -1755,11 +1752,6 @@ app.on('ready', async () => {
session: session.defaultSession,
});
installWebHandler({
enableHttp: true,
session: webSession,
});
logger = await logging.initialize(getMainWindow);
// Write buffered information into newly created logger.
@@ -2454,7 +2446,6 @@ ipc.on('get-config', async event => {
storageUrl: config.get<string>('storageUrl'),
updatesUrl: config.get<string>('updatesUrl'),
resourcesUrl: config.get<string>('resourcesUrl'),
artCreatorUrl: config.get<string>('artCreatorUrl'),
cdnUrl0: config.get<string>('cdn.0'),
cdnUrl2: config.get<string>('cdn.2'),
cdnUrl3: config.get<string>('cdn.3'),
@@ -2605,11 +2596,6 @@ function handleSignalRoute(route: ParsedSignalRoute) {
packId: route.args.packId,
packKey: Buffer.from(route.args.packKey, 'hex').toString('base64'),
});
} else if (route.key === 'artAuth') {
mainWindow.webContents.send('authorize-art-creator', {
token: route.args.token,
pubKeyBase64: route.args.pubKey,
});
} else if (route.key === 'groupInvites') {
mainWindow.webContents.send('show-group-via-link', {
value: route.args.inviteCode,
@@ -2895,7 +2881,6 @@ async function showStickerCreatorWindow() {
show: false,
webPreferences: {
...defaultWebPrefs,
partition: STICKER_CREATOR_PARTITION,
nodeIntegration: false,
nodeIntegrationInWorker: false,
sandbox: true,