feat:show strikes (#535)

* feat: add line break to invalid category

* feat: show strikes

* fix: typo

* chore: wordings

* feat: specify three reasons excluded
This commit is contained in:
SKINMAKER 2023-02-01 18:47:00 +08:00 committed by GitHub
parent 84eaaafde7
commit 3f5046b6c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 5 deletions

View File

@ -54,6 +54,16 @@ const PendingBot: NextPage<PendingBotProps> = ({ data }) => {
</div>
</>
}
<div className='pt-2'>
{data.strikes < 3 ? (
<p>
{3 - data.strikes} . . <br/>
'프라이빗 봇', '봇 오프라인', '공식 디스코드 서버 미참여' .
</p>
) : (
<p> .</p>
)}
</div>
</Message>
}
<p className='dark:text-gray-300 text-gray-800 text-base mt-3'>{data.intro}</p>
@ -176,7 +186,10 @@ export const getServerSideProps = async (ctx: Context) => {
const data = await get.botSubmit.load(JSON.stringify(ctx.query))
return {
props: {
data
data: data ? {
...data,
strikes: await get.botSubmitStrikes(data.id)
} : null
}
}
}
@ -195,7 +208,7 @@ const DenyPresetsArticle = {
<p><strong> </strong> .</p>
<p> 24 , .</p>
</>,
INVALID_CATEGORY: <p> . <strong> </strong> . <a className='text-blue-500 hover:text-blue-400' href='https://contents.koreanbots.dev/categories'></a> .</p>,
INVALID_CATEGORY: <p> . <strong> </strong> . <br/> <a className='text-blue-500 hover:text-blue-400' href='https://contents.koreanbots.dev/categories'></a> .</p>,
PRIVATE: <p> , . .
<ul className='list-inside list-disc'>
<li> ?</li>
@ -209,7 +222,7 @@ const DenyPresetsArticle = {
}
interface PendingBotProps {
data: SubmittedBot
data: SubmittedBot & {strikes: number | null}
}
interface Context extends NextPageContext {

View File

@ -407,8 +407,8 @@ async function submitBot(id: string, data: AddBotSubmit):Promise<1|2|3|4|5|Submi
const submits = await knex('submitted').select(['id']).where({ state: 0 }).andWhere('owners', 'LIKE', `%${id}%`)
if(submits.length > 1) return 1
const botId = data.id
const identicalSubmits = await knex('submitted').select(['id']).where({ id: botId, state: 2 }).whereNotIn('reason', ['PRIVATE', 'OFFLINE', 'ABSENT_AT_DISCORD']) // 다음 사유를 제외한 다른 사유의 3회 이상 거부 존재시 봇 등록 제한.
if(identicalSubmits.length >= 3) return 5
const strikes = await get.botSubmitStrikes(id)
if(strikes >= 3) return 5
const date = Math.round(+new Date()/1000)
const sameID = await knex('submitted').select(['id']).where({ id: botId, state: 0 })
const bot = await get.bot.load(data.id)
@ -684,6 +684,14 @@ async function denyBotSubmission(id: string, date: number, reason?: string) {
await knex('submitted').update({ state: 2, reason: reason || null }).where({ state: 0, id, date })
}
async function getBotSubmitStrikes(id: string) {
const identicalSubmits = await knex('submitted')
.select(['id'])
.where({ id, state: 2 })
.whereNotIn('reason', ['PRIVATE', 'OFFLINE', 'ABSENT_AT_DISCORD']) // 다음 사유를 제외한 다른 사유의 3회 이상 거부 존재시 봇 등록 제한.
return identicalSubmits.length
}
async function approveBotSubmission(id: string, date: number) {
const data = await knex('submitted').select(['id', 'date', 'category', 'lib', 'prefix', 'intro', 'desc', 'url', 'web', 'git', 'discord', 'state', 'owners', 'reason']).where({ state: 0, id, date })
if(!data[0]) return false
@ -836,6 +844,7 @@ export const get = {
ServerAuthorization,
botSubmitList: getBotSubmitList,
botSubmitHistory: getBotSubmitHistory,
botSubmitStrikes: getBotSubmitStrikes,
serverOwners: fetchServerOwners
}