同步设置
This commit is contained in:
1 parent
832261739f
commit
92aaf6fbb8
28 files changed
+705
-227
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { findUserByUsername } from '../db'
|
||||
import {
|
||||
findUserByUsername,
|
||||
getUploadSourcesForKeys,
|
||||
insertActivityLog
|
||||
} from '../db'
|
||||
import {
|
||||
getImageIndexRow,
|
||||
insertImageIndex,
|
||||
@@ -52,6 +56,24 @@ export async function applySiteSyncMedia(
|
||||
mediaType: media.mediaType
|
||||
})
|
||||
|
||||
if (
|
||||
media.uploadSource
|
||||
&& getUploadSourcesForKeys([media.key]).get(media.key) !== media.uploadSource
|
||||
) {
|
||||
insertActivityLog({
|
||||
action: 'upload',
|
||||
key: media.key,
|
||||
originalName: media.originalName,
|
||||
size: media.size,
|
||||
contentType: media.contentType,
|
||||
source: media.uploadSource,
|
||||
userId: owner?.id ?? null,
|
||||
backendId: backend.id,
|
||||
status: 'success',
|
||||
createdAt: media.uploadedAt
|
||||
})
|
||||
}
|
||||
|
||||
if (media.thumbKey) updateImageThumb(media.key, media.thumbKey)
|
||||
if (media.mediaType === 'video') {
|
||||
updateImageTranscode(media.key, {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ImageIndexRow } from '../image-index'
|
||||
import { getUploadSourcesForKeys } from '../db'
|
||||
import { getTagsForImageKeys } from '../tags'
|
||||
import type {
|
||||
SiteSyncMediaTransfer,
|
||||
@@ -10,6 +11,8 @@ export function toSiteSyncMediaTransfer(
|
||||
ownerUsername: string | null,
|
||||
tags: SiteSyncTag[]
|
||||
): SiteSyncMediaTransfer {
|
||||
const source = getUploadSourcesForKeys([row.key]).get(row.key)
|
||||
const uploadSource = source === 'web' || source === 'api' ? source : undefined
|
||||
return {
|
||||
key: row.key,
|
||||
ownerUsername,
|
||||
@@ -18,6 +21,7 @@ export function toSiteSyncMediaTransfer(
|
||||
size: row.size,
|
||||
uploadedAt: row.uploaded_at,
|
||||
mediaType: row.media_type,
|
||||
...(uploadSource ? { uploadSource } : {}),
|
||||
thumbKey: row.thumb_key,
|
||||
hlsKey: row.hls_key,
|
||||
transcodeStatus: row.transcode_status as SiteSyncMediaTransfer['transcodeStatus'],
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface SiteSyncMediaTransfer {
|
||||
size: number
|
||||
uploadedAt: string
|
||||
mediaType: MediaType
|
||||
uploadSource?: 'web' | 'api'
|
||||
thumbKey: string | null
|
||||
hlsKey: string | null
|
||||
transcodeStatus: TranscodeStatus
|
||||
|
||||
Reference in new issue
Block a user