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

Commit

Permalink
suplement: update analytics link, deployment script, upload group (#230)
Browse files Browse the repository at this point in the history
* update feature/redis (#229)

IORedis permits using nothing as an argument to create a new instance, using their default options ; why bother not doing so?

* suplement: update analytics link, deployment script, upload group

* update readme .env

* update contasct api

* fix get origin request for send message

Co-authored-by: λ <lambda@jikt.im>
  • Loading branch information
mgilangjanuar and lambdagg authored Jan 24, 2022
1 parent 7965d01 commit 539c16a
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 40 deletions.
324 changes: 297 additions & 27 deletions .github/workflows/build-prod.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This is the open source project of Google Drive/OneDrive/iCloud/Dropbox alternat
| PAYPAL_CLIENT_ID | yes | Client ID for PayPal subscription |
| PAYPAL_CLIENT_SECRET | yes | Client secret for PayPal subscription |
| PAYPAL_PLAN_PREMIUM_ID | yes | Product ID for premium plan |
| REDIS_URI | yes | Cache some responses from external services |
| REDIS_URI | no | Cache some responses from external services |
| UTILS_API_KEY | yes | Token key for make all servers communicate |

- Web variables
Expand Down
4 changes: 3 additions & 1 deletion server/src/api/v1/Contact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios'
import { Request, Response } from 'express'
import { Users } from '../../model/entities/Users'
import { Endpoint } from '../base/Endpoint'

@Endpoint.API()
Expand All @@ -8,9 +9,10 @@ export class Contact {
@Endpoint.POST()
public async send(req: Request, res: Response): Promise<any> {
const { from, message } = req.body
const user = await Users.createQueryBuilder('users').select(['users.subscription_id', 'users.midtrans_id', 'users.plan']).where({ username: from }).getOne()
await axios.post(`https://api.telegram.org/bot${process.env.TG_BOT_TOKEN}/sendMessage`, {
chat_id: process.env.TG_BOT_OWNER_ID,
text: `🛎 @${from} wants to contact you!\n\n${message}`
text: `🛎 @${from} wants to contact you!\n\n${message}\n\nfrom: ${req.headers['authority'] || req.headers.origin}${user ? `\nplan: ${user.plan}${user.subscription_id ? `\npaypal: ${user.subscription_id}` : ''}${user.midtrans_id ? `\nmidtrans: ${user.midtrans_id}` : ''}` : ''}`
})
return res.send({ success: true })
}
Expand Down
5 changes: 1 addition & 4 deletions server/src/service/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ export class Redis {
private redis: IOredis

private constructor() {
if (!process.env.REDIS_URI) {
throw new Error('REDIS_URI is not defined')
}
this.redis = new IORedis(process.env.REDIS_URI)
}

Expand Down Expand Up @@ -52,4 +49,4 @@ export class Redis {
await this.set(key, data, ex)
return data
}
}
}
2 changes: 1 addition & 1 deletion web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>TeleDrive - The Free Unlimited Cloud Storage</title>
<script async defer data-website-id="d189cc62-88d7-46dd-897c-5d5c88e4085b" src="https://analytics.teledriveapp.com/umami.js"></script>
<script async defer data-website-id="9cbb2118-c7eb-46e2-9b16-adf99945194c" src="https://analytics.teledriveapp.com/umami.js"></script>
<style>
@font-face { font-family: 'Plus Jakarta Display Medium'; src: url('PlusJakartaDisplay-Medium.woff'); }
@font-face { font-family: 'Plus Jakarta Display Medium'; src: url('PlusJakartaDisplay-Medium.woff2'); }
Expand Down
21 changes: 19 additions & 2 deletions web/src/pages/Contact.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SendOutlined } from '@ant-design/icons'
import { Button, Card, Col, Form, Input, Layout, notification, Row, Typography } from 'antd'
import { SendOutlined, WarningOutlined } from '@ant-design/icons'
import { Button, Card, Col, Form, Input, Layout, Modal, notification, Row, Typography } from 'antd'
import { useForm } from 'antd/lib/form/Form'
import React, { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import { req } from '../utils/Fetcher'

interface Props {
Expand All @@ -11,6 +12,7 @@ interface Props {
const Contact: React.FC<Props> = ({ me }) => {
const [form] = useForm()
const [loading, setLoading] = useState<boolean>()
const [confirmation, setConfirmation] = useState<boolean>()

useEffect(() => {
form.setFieldsValue({ from: me?.user.username })
Expand Down Expand Up @@ -38,13 +40,17 @@ const Contact: React.FC<Props> = ({ me }) => {
}, [])

const send = async () => {
if (!confirmation) {
return setConfirmation(true)
}
setLoading(true)
await req.post('/contact/send', form.getFieldsValue())
form.setFieldsValue({ message: null })
notification.success({
message: 'Sent!',
description: 'Your message sent successfully!'
})
setConfirmation(undefined)
setLoading(false)
}

Expand Down Expand Up @@ -74,6 +80,17 @@ const Contact: React.FC<Props> = ({ me }) => {
</Col>
</Row>
</Layout.Content>
<Modal visible={confirmation}
title={<><WarningOutlined /> Confirmation</>}
onCancel={() => setConfirmation(undefined)}
onOk={send}
okText="Confirm"
cancelButtonProps={{ shape: 'round' }}
okButtonProps={{ type: 'primary', loading, shape: 'round' }}>
<Typography.Paragraph>
Please double check your username (<Link target="_blank" to={{ pathname: `https://t.me/${form.getFieldValue('from')}` }}>@{form.getFieldValue('from')}</Link>) because we will reply your message to this Telegram account.
</Typography.Paragraph>
</Modal>
</>
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Footer: React.FC<Props> = () => {
<Link to="/faq">FAQ</Link>
<Link to="/privacy">Privacy Policy</Link>
<Link to="/refund">Refund Policy</Link>
<Link target="_blank" to={{ pathname: 'https://analytics.teledriveapp.com/share/I4NhU6ih/TeleDrive' }}>Analytics</Link>
<Link target="_blank" to={{ pathname: 'https://analytics.teledriveapp.com/share/4RhiPDRP/TeleDrive' }}>Analytics</Link>
</Space>
</Col>
</Row>
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const Navbar: React.FC<Props> = ({ user }) => {
<Menu.Item onClick={() => history.push('/terms')} key="terms">Terms</Menu.Item>
<Menu.Item onClick={() => history.push('/refund')} key="refund">Refund Policy</Menu.Item>
<Menu.Item onClick={() => window.open('https://mgilangjanuar.notion.site/TeleDrive-Blog-ea8c422dfa8046cda6655cddec0cd8e8', '_blank')} key="blog">Blog</Menu.Item>
<Menu.Item onClick={() => window.open('https://analytics.teledriveapp.com/share/I4NhU6ih/TeleDrive', '_blank')} key="analytics">Analytics</Menu.Item>
<Menu.Item onClick={() => window.open('https://analytics.teledriveapp.com/share/4RhiPDRP/TeleDrive', '_blank')} key="analytics">Analytics</Menu.Item>
</Menu>
</Layout.Header>

Expand Down
5 changes: 3 additions & 2 deletions web/src/pages/dashboard/components/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ const Upload: React.FC<Props> = ({ dataFileList: [fileList, setFileList], parent
}
}

const group = 1
const group = 2
await uploadPart(0)
for (let i = 1; i < parts - 1; i += group) {
if (deleted) break
const others = Array.from(Array(i + group).keys()).slice(i, Math.min(parts - 1, i + group))
await Promise.all(others.map(async j => await uploadPart(j)))
}
if (parts - 1 > 0) {
if (!deleted && parts - 1 > 0) {
await uploadPart(parts - 1)
}
}
Expand Down

0 comments on commit 539c16a

Please sign in to comment.