updated mobile media uploader logic to be more redundant
This commit is contained in:
@@ -424,6 +424,60 @@ export class MobileRepository {
|
||||
);
|
||||
}
|
||||
|
||||
findMediaAssetByExternalMediaId(
|
||||
fctx: FlowExecCtx,
|
||||
deviceId: number,
|
||||
externalMediaId: string,
|
||||
): ResultAsync<{ id: number; fileId: string } | null, Err> {
|
||||
return ResultAsync.fromPromise(
|
||||
this.db
|
||||
.select({
|
||||
id: mobileMediaAsset.id,
|
||||
fileId: mobileMediaAsset.fileId,
|
||||
})
|
||||
.from(mobileMediaAsset)
|
||||
.where(
|
||||
and(
|
||||
eq(mobileMediaAsset.deviceId, deviceId),
|
||||
eq(mobileMediaAsset.externalMediaId, externalMediaId),
|
||||
),
|
||||
)
|
||||
.limit(1),
|
||||
(error) =>
|
||||
mobileErrors.listMediaFailed(
|
||||
fctx,
|
||||
error instanceof Error ? error.message : String(error),
|
||||
),
|
||||
).map((rows) => rows[0] ?? null);
|
||||
}
|
||||
|
||||
findMediaAssetByHash(
|
||||
fctx: FlowExecCtx,
|
||||
deviceId: number,
|
||||
hash: string,
|
||||
): ResultAsync<{ id: number; fileId: string } | null, Err> {
|
||||
return ResultAsync.fromPromise(
|
||||
this.db
|
||||
.select({
|
||||
id: mobileMediaAsset.id,
|
||||
fileId: mobileMediaAsset.fileId,
|
||||
})
|
||||
.from(mobileMediaAsset)
|
||||
.where(
|
||||
and(
|
||||
eq(mobileMediaAsset.deviceId, deviceId),
|
||||
eq(mobileMediaAsset.hash, hash),
|
||||
),
|
||||
)
|
||||
.limit(1),
|
||||
(error) =>
|
||||
mobileErrors.listMediaFailed(
|
||||
fctx,
|
||||
error instanceof Error ? error.message : String(error),
|
||||
),
|
||||
).map((rows) => rows[0] ?? null);
|
||||
}
|
||||
|
||||
listDevices(
|
||||
fctx: FlowExecCtx,
|
||||
filters: ListMobileDevicesFilters,
|
||||
|
||||
Reference in New Issue
Block a user