fix(electron): incorrect app allow list logic for recording (#11368)

This commit is contained in:
pengx17
2025-04-01 14:19:29 +00:00
parent 7f98420061
commit 2d304adf15
3 changed files with 21 additions and 89 deletions

View File

@@ -68,14 +68,14 @@ export function setupRecordingEvents(frameworkProvider: FrameworkProvider) {
(async () => { (async () => {
// name + timestamp(readable) + extension // name + timestamp(readable) + extension
const attachmentName = const attachmentName =
(status.appName ?? 'System Audio') + ' ' + timestamp + '.webm'; (status.appName ?? 'System Audio') + ' ' + timestamp + '.opus';
// add size and sourceId to the attachment later // add size and sourceId to the attachment later
const attachmentId = doc.addBlock( const attachmentId = doc.addBlock(
'affine:attachment', 'affine:attachment',
{ {
name: attachmentName, name: attachmentName,
type: 'audio/webm', type: 'audio/opus',
}, },
noteId noteId
); );

View File

@@ -16,7 +16,7 @@ import {
Subject, Subject,
throttleTime, throttleTime,
} from 'rxjs'; } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators'; import { filter, map, shareReplay } from 'rxjs/operators';
import { isMacOS, shallowEqual } from '../../shared/utils'; import { isMacOS, shallowEqual } from '../../shared/utils';
import { beforeAppQuit } from '../cleanup'; import { beforeAppQuit } from '../cleanup';
@@ -157,7 +157,8 @@ function setupNewRunningAppGroup() {
groupStream$.pipe( groupStream$.pipe(
distinctUntilChanged((prev, curr) => prev.isRunning === curr.isRunning) distinctUntilChanged((prev, curr) => prev.isRunning === curr.isRunning)
) )
) ),
filter(group => isAppNameAllowed(group.name))
); );
appGroups$.value.forEach(group => { appGroups$.value.forEach(group => {
@@ -391,8 +392,7 @@ function getAllApps(): TappableAppInfo[] {
v !== null && v !== null &&
!v.bundleIdentifier.startsWith('com.apple') && !v.bundleIdentifier.startsWith('com.apple') &&
!v.bundleIdentifier.startsWith('pro.affine') && !v.bundleIdentifier.startsWith('pro.affine') &&
v.processId !== process.pid && v.processId !== process.pid
isAppNameAllowed(v.name)
); );
return filteredApps; return filteredApps;
} }
@@ -604,7 +604,7 @@ export async function readyRecording(id: number, buffer: Buffer) {
const filepath = path.join( const filepath = path.join(
SAVED_RECORDINGS_DIR, SAVED_RECORDINGS_DIR,
`${recordingStatus.appGroup?.bundleIdentifier ?? 'unknown'}-${recordingStatus.id}-${recordingStatus.startTime}.webm` `${recordingStatus.appGroup?.bundleIdentifier ?? 'unknown'}-${recordingStatus.id}-${recordingStatus.startTime}.opus`
); );
await fs.writeFile(filepath, buffer); await fs.writeFile(filepath, buffer);

View File

@@ -1,8 +1,8 @@
{ {
"v": "5.12.1", "v": "5.12.1",
"fr": 60, "fr": 60,
"ip": 0, "ip": 35,
"op": 106, "op": 64,
"w": 24, "w": 24,
"h": 24, "h": 24,
"nm": "light", "nm": "light",
@@ -113,18 +113,6 @@
"t": 5, "t": 5,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1] "s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
}, },
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 10,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
},
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 95,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
},
{ {
"t": 101, "t": 101,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1] "s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
@@ -264,18 +252,6 @@
"t": 5, "t": 5,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1] "s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
}, },
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 10,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
},
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 95,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
},
{ {
"t": 101, "t": 101,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1] "s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
@@ -433,19 +409,8 @@
{ {
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 1, "a": 0,
"k": [ "k": [0.478431373835, 0.478431373835, 0.478431373835, 1],
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 95,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
},
{
"t": 101,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
}
],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },
@@ -598,19 +563,8 @@
{ {
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 1, "a": 0,
"k": [ "k": [0.478431373835, 0.478431373835, 0.478431373835, 1],
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 95,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
},
{
"t": 101,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
}
],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },
@@ -840,7 +794,7 @@
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 0, "a": 0,
"k": [0.117647058824, 0.588235294118, 0.921568627451, 1], "k": [0.478431402468, 0.478431402468, 0.478431402468, 1],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },
@@ -1070,7 +1024,7 @@
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 0, "a": 0,
"k": [0.117647058824, 0.588235294118, 0.921568627451, 1], "k": [0.478431402468, 0.478431402468, 0.478431402468, 1],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },
@@ -1300,7 +1254,7 @@
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 0, "a": 0,
"k": [0.117647058824, 0.588235294118, 0.921568627451, 1], "k": [0.478431402468, 0.478431402468, 0.478431402468, 1],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },
@@ -1530,7 +1484,7 @@
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 0, "a": 0,
"k": [0.117647058824, 0.588235294118, 0.921568627451, 1], "k": [0.478431402468, 0.478431402468, 0.478431402468, 1],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },
@@ -1683,19 +1637,8 @@
{ {
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 1, "a": 0,
"k": [ "k": [0.478431373835, 0.478431373835, 0.478431373835, 1],
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 5,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
},
{
"t": 10,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
}
],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },
@@ -1848,19 +1791,8 @@
{ {
"ty": "fl", "ty": "fl",
"c": { "c": {
"a": 1, "a": 0,
"k": [ "k": [0.478431373835, 0.478431373835, 0.478431373835, 1],
{
"i": { "x": [0.833], "y": [0.833] },
"o": { "x": [0.167], "y": [0.167] },
"t": 5,
"s": [0.478431373835, 0.478431373835, 0.478431373835, 1]
},
{
"t": 10,
"s": [0.117647059262, 0.588235318661, 0.921568632126, 1]
}
],
"ix": 4 "ix": 4
}, },
"o": { "a": 0, "k": 100, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 5 },