Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #202 from mgilangjanuar/staging
Browse files Browse the repository at this point in the history
Release v1.6.5
  • Loading branch information
mgilangjanuar authored Jan 14, 2022
2 parents aaacd16 + 2da2d3f commit e5e9853
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teledrive",
"version": "1.6.4",
"version": "1.6.5",
"repository": "git@github.com:mgilangjanuar/teledrive.git",
"author": "M Gilang Januar <mgilangjanuar@gmail.com>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "server",
"version": "1.6.4",
"version": "1.6.5",
"main": "dist/index.js",
"license": "MIT",
"private": true,
Expand Down Expand Up @@ -83,4 +83,4 @@
"rimraf": "^3.0.2",
"typescript": "^4.4.2"
}
}
}
16 changes: 15 additions & 1 deletion server/src/api/v1/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,28 @@ export class Files {
@Endpoint.DELETE('/:id', { middlewares: [Auth] })
public async remove(req: Request, res: Response): Promise<any> {
const { id } = req.params
const { affected } = await Model.createQueryBuilder('files')
const { deleteMessage } = req.query
const { affected, raw } = await Model.createQueryBuilder('files')
.delete()
.where({ id, user_id: req.user.id })
.returning('*')
.execute()
if (!affected) {
throw { status: 404, body: { error: 'File not found' } }
}

const file = raw[0]
if (deleteMessage && ['true', '1'].includes(deleteMessage as string) && !file?.forward_info) {
try {
await req.tg.invoke(new Api.messages.DeleteMessages({ id: [Number(file.message_id)], revoke: true }))
} catch (error) {
try {
await req.tg.invoke(new Api.channels.DeleteMessages({ id: [Number(file.message_id)], channel: 'me' }))
} catch (error) {
// ignore
}
}
}
return res.send({ file: { id } })
}

Expand Down
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web",
"version": "1.6.4",
"version": "1.6.5",
"private": true,
"dependencies": {
"@ideasio/add-to-homescreen-react": "^1.0.10",
Expand Down Expand Up @@ -101,4 +101,4 @@
"workbox-strategies": "^5.1.3",
"workbox-streams": "^5.1.3"
}
}
}
12 changes: 10 additions & 2 deletions web/src/pages/dashboard/components/Remove.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WarningOutlined } from '@ant-design/icons'
import { Modal, Typography } from 'antd'
import { Checkbox, Form, Modal, Typography } from 'antd'
import React, { useState } from 'react'
import { req } from '../../../utils/Fetcher'

Expand All @@ -15,11 +15,14 @@ const Remove: React.FC<Props> = ({
onFinish }) => {

const [loadingRemove, setLoadingRemove] = useState<boolean>()
const [deleteMessage, setDeleteMessage] = useState<boolean>()

const remove = async (ids: string[]) => {
setLoadingRemove(true)
try {
await Promise.all(ids.map(async id => await req.delete(`/files/${id}`)))
await Promise.all(ids.map(async id => await req.delete(`/files/${id}`, {
params: { deleteMessage: deleteMessage ? 'true' : undefined }
})))
} catch (error) {
// ignore
}
Expand All @@ -40,6 +43,11 @@ const Remove: React.FC<Props> = ({
<Typography.Paragraph>
Are you sure to delete {selectDeleted?.length > 1 ? `${selectDeleted?.length} objects` : selectDeleted?.[0]?.name }?
</Typography.Paragraph>
<Form.Item>
<Checkbox checked={deleteMessage} onChange={({ target }) => setDeleteMessage(target.checked)}>
Delete from Saved Messages too
</Checkbox>
</Form.Item>
</Modal>
}

Expand Down

0 comments on commit e5e9853

Please sign in to comment.