Skip to content

Commit

Permalink
Release v2.1 (#441)
Browse files Browse the repository at this point in the history
* feat: added datadog

* fix(deps): update dependency yup-locales-ko to v1.2.0

* fix: prevent perm missing

* fix: invalid start script

* fix(deps): update dependency formik to v2.2.9 (#409)

* chore: changed some header

* deps: updated sentry

* feat: added datadog metrix

* fix: error causing at custom git url

* chore: removed key file

CHANGED KEY

* types: holding missing flag

* feat: cors header

* feat: updated api docs

* deps: updated deps for security

* ci: handling sentry release

* ci: handling sentry

* Bug Fixes (#438)

* fix: invalid sql

* fix: fixed formatting number for null

close: #433

* chore: added more margin for ad

* typo: fixed typo issue

* Improved Report and changed email address (#440)

* feat: added report page for bot

* feat: added report page for user

* feat: blocking user reporting self

* feat: changed emails

* refactor: changed category handler style

* release: version changed to v2.1

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 4, 2021
1 parent b17744f commit 282fc08
Show file tree
Hide file tree
Showing 24 changed files with 2,001 additions and 1,886 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ jobs:
with:
mysql database: 'discordbots'
mysql root password: 'test'
- name: Wait for MySQL
run: |
while ! mysqladmin ping --host=127.0.0.1 --password=test --silent; do
sleep 1
done
- name: Run Jest
run: yarn test
- name: Generate RSA Key Pair
Expand All @@ -56,12 +51,14 @@ jobs:
run: |
mv .env.demo.local .env.production.local
printf 'MARIADB_ROOT_PASSWORD=YOUSHALLNOTPASS\nCOMMIT_HASH=${{ github.sha }}' > .env
- name: Create needed files
run: echo '{"tester":"DEMO_KEY"}' > secret.json
printf 'defaults.url=https://sentry.io/\ndefaults.org=koreanbots\ndefaults.project=client' > sentry.properties
- name: Build
run: yarn build
env:
CI: true
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}

# docker:
# needs:
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

## English

Please [mail](mailto:koreanbots.dev@gmail.com) us!
Please [mail](mailto:team@koreanbots.dev) us!
2 changes: 1 addition & 1 deletion api-docs
78 changes: 78 additions & 0 deletions components/ReportTemplate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { FC, useState } from 'react'
import dynamic from 'next/dynamic'
import { FormikErrors, FormikTouched } from 'formik'

const Button = dynamic(() => import('@components/Button'))
const TextArea = dynamic(() => import('@components/Form/TextArea'))

export const Check: FC<{ checked: boolean, text: string }> = ({ checked, text }) => <>
{checked && <i className='text-green-400 fas fa-check-circle mr-1' />}
{text}
</>

export const SubmitButton: FC = () => <div className='text-right'>
<Button type='submit'>제출</Button>
</div>

export const TextField: FC<ReportTemplateProps> = ({ values, errors, touched, setFieldValue }) => <>
<TextArea name='description' placeholder='최대한 자세하게 설명해주세요!' value={values.description} setValue={(value) => setFieldValue('description', value)} />
<div className='mt-1 text-red-500 text-xs font-light'>{errors.description && touched.description ? errors.description : null}</div>
<SubmitButton />
</>

export const DMCA: FC<ReportTemplateProps> = ({ values, errors, touched, setFieldValue }) => {
const [ isOwner, setOwner ] = useState(null)
const [ contacted, setContacted ] = useState(null)
return <div>
<h3 className='font-bold my-2'>권리자와는 어떤 관계인가요?</h3>
<Button onClick={() => setOwner(true)}>
<Check checked={isOwner} text='권리자 본인 혹은 대리인입니다.' />
</Button>
<Button onClick={() => setOwner(false)}>
<Check checked={isOwner === false} text='권리자가 아닙니다.' />
</Button>
{
isOwner === true ? <>
<h3 className='font-bold my-2'>권리 침해자에게 연락하여 라이선스 위반사항을 고지하셨나요?</h3>
<Button onClick={() => setContacted(true)}>
<Check checked={contacted} text='최대한 연락을 시도하였지만 개선되지 않았습니다.' />
</Button>
<Button onClick={() => setContacted(false)}>
<Check checked={contacted === false} text='아니요, 아직 연락하지 않았습니다.' />
</Button>
{
contacted ? <div>
<h3 className='font-bold mt-2'>설명</h3>
<p className='text-gray-400 text-sm mb-1'>반드시 아래 항목들을 포함해야합니다.</p>
<ul className='text-gray-400 text-sm mb-1 list-disc list-inside'>
<li>권리자 본인임을 증명 (단체 소속인 경우 어떤 자격으로 단체를 대표하여 신고하는지 설명)</li>
<li>본인의 권리를 입증 (원본 컨텐츠의 주소, 라이선스 등을 포함)</li>
</ul>
<p className='text-gray-400 text-sm mb-1'>컨텐츠를 추가로 첨부해야하는 경우 <a className='text-blue-400' target='_blank' rel='noreferrer' href={`mailto:[email protected]?subject=${encodeURI('[DMCA] 추가 컨텐츠')}&body=${encodeURI('디스코드 태그:')}`}>[email protected]</a>의 이메일로 첨부해주시고, 해당 이메일로 첨부했음을 아래 설명에 기재해주세요.</p>
<TextField values={values} errors={errors} touched={touched} setFieldValue={setFieldValue} />
</div>
: contacted === false ? <>
<h2 className='font-bold mt-4 text-xl'>먼저 권리 침해자에게 연락을 시도해주세요.</h2>
<p>본인의 권리를 침해하신 분께 먼저 연락을 시도하셔서 위반사항을 고지하시고, 연락이 불가하다면 신고 기능을 이용해주세요.</p>
</> : ''
}
</>
: isOwner === false ? <>
<h2 className='font-bold mt-4 text-xl'>아쉽지만, 권리자 본인 혹은 대리인만 신고하실 수 있습니다.</h2>
<p>권리자 분께 말씀드려, 권리자 본인이 직접 신고하시도록 해주세요!</p>
</> : ''
}
</div>
}

interface ReportValues {
category: string | null
description: string
_csrf: string
}
interface ReportTemplateProps {
values?: ReportValues
errors?: FormikErrors<ReportValues>
touched?: FormikTouched<ReportValues>
setFieldValue?(field: string, value: unknown): void
}
2 changes: 1 addition & 1 deletion migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use discordbots;

-- bots TABLE
ALTER TABLE `bots` CHANGE `servers` `servers` INT(11) NULL DEFAULT NULL, CHANGE `web` `web` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `git` `git` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `url` `url` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `category` `category` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '\'[]\'', CHANGE `status` `status` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, CHANGE `avatar` `avatar` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `tag` `tag` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, CHANGE `discord` `discord` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `state` `state` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '\'ok\'', CHANGE `vanity` `vanity` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, CHANGE `bg` `bg` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, CHANGE `banner` `banner` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `bots` CHANGE `servers` `servers` INT(11) NULL DEFAULT NULL, CHANGE `web` `web` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `git` `git` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `url` `url` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `category` `category` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '\'[]\'', CHANGE `status` `status` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, CHANGE `avatar` `avatar` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `tag` `tag` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, CHANGE `discord` `discord` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL, CHANGE `state` `state` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ok', CHANGE `vanity` `vanity` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, CHANGE `bg` `bg` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, CHANGE `banner` `banner` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;

-- USING NULL
UPDATE `bots` SET web=NULL where web='false' or web='';
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "koreanbots",
"version": "2.0.0",
"version": "2.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"pre-build": "git init && git submodule init && git submodule update --remote",
"build": "npm run pre-build && next build",
"start": "NODE_OPTIONS='--require dd-trace/init' next start | (sleep 1; wget http://localhost:3000/api/v2/management/load -O /dev/null)",
"start": "NODE_OPTIONS='--require dd-trace/init' next start | (sleep 2; wget http://localhost:3000/api/v2/management/load -O /dev/null)",
"lint": "eslint --ext ts,tsx .",
"prettier": "prettier --write **/*",
"lint:fix": "eslint --ext ts,tsx . --fix",
Expand All @@ -16,10 +16,10 @@
"dependencies": {
"@fortawesome/fontawesome-free": "5.15.3",
"@hcaptcha/react-hcaptcha": "0.3.6",
"@sentry/nextjs": "6.5.1",
"@sentry/node": "6.5.1",
"@sentry/react": "6.5.1",
"@sentry/tracing": "6.5.1",
"@sentry/nextjs": "6.8.0",
"@sentry/node": "6.8.0",
"@sentry/react": "6.8.0",
"@sentry/tracing": "6.8.0",
"abort-controller": "3.0.0",
"autoprefixer": "10.2.5",
"badgen": "3.2.2",
Expand All @@ -33,7 +33,7 @@
"emoji-mart": "3.0.1",
"erlpack": "0.1.3",
"express-rate-limit": "5.2.6",
"formik": "2.2.8",
"formik": "2.2.9",
"generate-license-file": "1.1.0",
"josa": "3.0.1",
"jsonwebtoken": "8.5.1",
Expand All @@ -46,7 +46,7 @@
"next-session": "3.4.0",
"node-emoji": "1.10.0",
"nprogress": "0.2.0",
"postcss": "8.3.0",
"postcss": "8.3.5",
"postcss-preset-env": "6.7.0",
"rc-tooltip": "5.1.1",
"react": "17.0.2",
Expand All @@ -59,7 +59,7 @@
"react-sortable-hoc": "2.0.0",
"react-use-clipboard": "1.0.7",
"sanitize-html": "2.4.0",
"tailwindcss": "2.1.4",
"tailwindcss": "2.2.4",
"tlru": "1.0.2",
"twemoji": "13.1.0",
"url-regex-safe": "2.0.2",
Expand Down
2 changes: 1 addition & 1 deletion pages/addbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const AddBot:NextPage<AddBotProps> = ({ logged, user, csrfToken, theme }) => {
<li>봇 소유자가 두 명 이상인가요? 봇 소유자는 봇이 승인된 뒤, 더 추가하실 수 있습니다.</li>
<li>본인이 봇의 소유자라는 것을 증명할 수 있나요? 본인이 봇 소유자임을 증명하려면, 태그가 포함되어야 합니다.</li>
다음 명령어(접두사로 시작하는) 중 하나 이상에 소유자를 표시하셔야 합니다. <br/>
<strong>빗금 명렁어(Slash Command) 봇인 경우에도 적용됩니다.</strong> 빗금 명령어가 아닌 다음 일반 명령어가 작동해야합니다. (심사시에 빗금 명령어 권한이 따로 부여되지 않습니다.)
<strong>빗금 명령어(Slash Command) 봇인 경우에도 적용됩니다.</strong> 빗금 명령어가 아닌 다음 일반 명령어가 작동해야합니다. (심사시에 빗금 명령어 권한이 따로 부여되지 않습니다.)
<ul>
<li>- 도움 명령어: 도움, 도움말, 명령어, help, commands</li>
<li>- 도움 명령어에 소유자임을 나타내고 싶지 않으시다면, 아래 명령어를 만들어주세요<br/>
Expand Down
6 changes: 6 additions & 0 deletions pages/api/v2/bots/[id]/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextApiRequest } from 'next'
import rateLimit from 'express-rate-limit'
import { MessageEmbed } from 'discord.js'
import tracer from 'dd-trace'

import { CaptchaVerify, get, put, remove, update } from '@utils/Query'
import ResponseWrapper from '@utils/ResponseWrapper'
Expand Down Expand Up @@ -83,6 +84,11 @@ const Bots = RequestHandler()
})
const userinfo = await get.user.load(user)
await getBotReviewLogChannel().send(new MessageEmbed().setAuthor(`${userinfo.username}#${userinfo.tag}`, KoreanbotsEndPoints.URL.root + KoreanbotsEndPoints.CDN.avatar(userinfo.id, { format: 'png', size: 256 }), KoreanbotsEndPoints.URL.user(userinfo.id)).setTitle('대기 중').setColor('GREY').setDescription(`[${result.id}/${result.date}](${KoreanbotsEndPoints.URL.submittedBot(result.id, result.date)})`).setTimestamp())
await tracer.trace('botSubmits.submitted', (async span => {
span.setTag('id', result.id)
span.setTag('date', result.date)
span.setTag('user', userinfo.id)
}))
return ResponseWrapper(res, { code: 200, data: result })
})
.delete(async (req: DeleteApiRequest, res) => {
Expand Down
10 changes: 8 additions & 2 deletions pages/api/v2/management/bots/submits/[id]/[date]/approve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NextApiRequest } from 'next'
import { MessageEmbed } from 'discord.js'
import tracer from 'dd-trace'

import RequestHandler from '@utils/RequestHandler'
import ResponseWrapper from '@utils/ResponseWrapper'
Expand All @@ -19,8 +20,13 @@ const ApproveBotSubmit = RequestHandler()
get.botSubmit.clear(JSON.stringify({ id: req.query.id, date: req.query.date }))
get.bot.clear(req.query.id)
const embed = new MessageEmbed().setTitle('승인').setColor('GREEN').setDescription(`[${submit.id}/${submit.date}](${KoreanbotsEndPoints.URL.submittedBot(submit.id, submit.date)})`).setTimestamp()
if(req.body.note) embed.addField('📃 정보', req.body.note)
if(req.body.reviewer) embed.addField('📃 정보', `심사자: ${req.body.reviewer}`)
await getBotReviewLogChannel().send(embed)
await tracer.trace('botSubmits.approve', (async span => {
span.setTag('id', submit.id)
span.setTag('date', submit.date)
span.setTag('reviewer', req.body.reviewer)
}))
return ResponseWrapper(res, { code: 200 })
})

Expand All @@ -30,7 +36,7 @@ interface ApiRequest extends NextApiRequest {
date: string
}
body: {
note?: string
reviewer?: string
}
}

Expand Down
4 changes: 2 additions & 2 deletions pages/api/v2/management/bots/submits/[id]/[date]/deny.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DenyBotSubmit = RequestHandler()
await update.denyBotSubmission(submit.id, submit.date, req.body.reason)
get.botSubmit.clear(JSON.stringify({ id: req.query.id, date: req.query.date }))
const embed = new MessageEmbed().setTitle('거부').setColor('RED').setDescription(`[${submit.id}/${submit.date}](${KoreanbotsEndPoints.URL.submittedBot(submit.id, submit.date)})`).setTimestamp()
if(req.body.note || req.body.reason) embed.addField('📃 정보', `${req.body.reason ? `사유: ${BotSubmissionDenyReasonPresetsName[req.body.reason] || req.body.reason}\n`: ''}${req.body.note ? `${req.body.note}` : ''}`)
if(req.body.reviewer || req.body.reason) embed.addField('📃 정보', `${req.body.reason ? `사유: ${BotSubmissionDenyReasonPresetsName[req.body.reason] || req.body.reason}\n`: ''}${req.body.reviewer ? `심사자: ${req.body.reviewer}` : ''}`)
await getBotReviewLogChannel().send(embed)
return ResponseWrapper(res, { code: 200 })
})
Expand All @@ -29,7 +29,7 @@ interface ApiRequest extends NextApiRequest {
}
body: {
reason?: string
note?: string
reviewer: string
}
}

Expand Down
16 changes: 6 additions & 10 deletions pages/bots/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { get } from '@utils/Query'
import Day from '@utils/Day'
import { ReportSchema } from '@utils/Yup'
import Fetch from '@utils/Fetch'
import { checkBotFlag, checkUserFlag, formatNumber, parseCookie, redirectTo } from '@utils/Tools'
import { checkBotFlag, checkUserFlag, formatNumber, parseCookie } from '@utils/Tools'
import { getToken } from '@utils/Csrf'

import NotFound from '../../404'
Expand Down Expand Up @@ -217,15 +217,11 @@ const Bots: NextPage<BotsProps> = ({ data, desc, date, user, theme, csrfToken })
/>
))}
<div className='list grid'>
<a className='text-red-600 hover:underline cursor-pointer' onClick={() => {
if(!user) {
localStorage.redirectTo = window.location.href
redirectTo(router, 'login')
}
else setReportModal(true)
}} aria-hidden='true'>
<i className='far fa-flag' /> 신고하기
</a>
<Link href={`/bots/${router.query.id}/report`}>
<a className='text-red-600 hover:underline cursor-pointer' aria-hidden='true'>
<i className='far fa-flag' /> 신고하기
</a>
</Link>
<Modal header={`${data.name}#${data.tag} 신고하기`} closeIcon isOpen={reportModal} onClose={() => {
setReportModal(false)
setReportRes(null)
Expand Down
Loading

0 comments on commit 282fc08

Please sign in to comment.