mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 14:30:22 +00:00
Merge pull request #406 from koreanbots/master
Fixed Ad Stuffs and blocking users at API side
This commit is contained in:
commit
99b3e20465
2
api-docs
2
api-docs
@ -1 +1 @@
|
|||||||
Subproject commit 6d23d8547697557601eb763eb3af9d318d2610d7
|
Subproject commit 3636d4a1519f412ede7ab0b301dd8ca4bdd16a7b
|
||||||
@ -1,21 +1,6 @@
|
|||||||
import { useEffect } from 'react'
|
import AdSense from 'react-adsense'
|
||||||
import Logger from '@utils/Logger'
|
|
||||||
|
|
||||||
const Advertisement: React.FC<AdvertisementProps> = ({ size = 'short' }) => {
|
const Advertisement: React.FC<AdvertisementProps> = ({ size = 'short' }) => {
|
||||||
useEffect(() => {
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
window.adsbygoogle = window.adsbygoogle || []
|
|
||||||
try {
|
|
||||||
window.adsbygoogle.push({})
|
|
||||||
Logger.debug('Ad Pushed')
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Logger.debug('Ad Push Fail')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return <div className='py-5'>
|
return <div className='py-5'>
|
||||||
<div
|
<div
|
||||||
className={`z-0 mx-auto w-full text-center text-white ${
|
className={`z-0 mx-auto w-full text-center text-white ${
|
||||||
@ -24,14 +9,11 @@ const Advertisement: React.FC<AdvertisementProps> = ({ size = 'short' }) => {
|
|||||||
style={size === 'short' ? { height: '90px' } : { height: '330px' }}
|
style={size === 'short' ? { height: '90px' } : { height: '330px' }}
|
||||||
>
|
>
|
||||||
{process.env.NODE_ENV === 'production' ? (
|
{process.env.NODE_ENV === 'production' ? (
|
||||||
<ins
|
<AdSense.Google
|
||||||
className='adsbygoogle'
|
style={{ display: 'inline-block', width: '100%', height: size === 'short' ? '90px' : '330px'}}
|
||||||
style={{ display: 'block', width: '100%' }}
|
client='ca-pub-4856582423981759'
|
||||||
data-ad-client='ca-pub-4856582423981759'
|
slot='3250141451'
|
||||||
data-ad-slot='3250141451'
|
format=''
|
||||||
data-ad-format={size === 'short' ? 'horizontal' : 'vertical'}
|
|
||||||
data-full-width-responsive='true'
|
|
||||||
data-adtest='on'
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
'Advertisement'
|
'Advertisement'
|
||||||
|
|||||||
@ -49,6 +49,7 @@
|
|||||||
"postcss-preset-env": "6.7.0",
|
"postcss-preset-env": "6.7.0",
|
||||||
"rc-tooltip": "5.1.1",
|
"rc-tooltip": "5.1.1",
|
||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
|
"react-adsense": "0.1.0",
|
||||||
"react-dom": "17.0.2",
|
"react-dom": "17.0.2",
|
||||||
"react-hotkeys": "2.0.0",
|
"react-hotkeys": "2.0.0",
|
||||||
"react-responsive-modal": "6.0.1",
|
"react-responsive-modal": "6.0.1",
|
||||||
|
|||||||
@ -53,7 +53,11 @@ const Callback = RequestHandler().get(async (req: ApiRequest, res) => {
|
|||||||
email: user.email,
|
email: user.email,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
discriminator: user.discriminator,
|
discriminator: user.discriminator,
|
||||||
|
verified: user.verified
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if(userToken === 1) return res.redirect(301, 'https://docs.koreanbots.dev/bots/account/unverified')
|
||||||
|
else if(userToken === 2) return res.redirect(301, 'https://docs.koreanbots.dev/bots/account/blocked')
|
||||||
const info = verify(userToken)
|
const info = verify(userToken)
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
'set-cookie',
|
'set-cookie',
|
||||||
|
|||||||
@ -322,16 +322,11 @@ const Bots: NextPage<BotsProps> = ({ data, desc, date, user, theme, csrfToken })
|
|||||||
<p>자세한 내용은 <a className='text-blue-500 hover:text-blue-400' href='https://blog.koreanbots.dev/first-hackathon-results/'>해당 글</a>을 확인해주세요.</p>
|
<p>자세한 내용은 <a className='text-blue-500 hover:text-blue-400' href='https://blog.koreanbots.dev/first-hackathon-results/'>해당 글</a>을 확인해주세요.</p>
|
||||||
</Segment> : ''
|
</Segment> : ''
|
||||||
}
|
}
|
||||||
<div className='markdown-body pt-4 w-full'>
|
<Segment className='my-4'>
|
||||||
<Segment className='my-4'>
|
<Markdown text={desc}/>
|
||||||
<Markdown text={desc}/>
|
</Segment>
|
||||||
</Segment>
|
<Advertisement />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
<div className='pt-5'>
|
|
||||||
<Advertisement />
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { NextPage} from 'next'
|
import { NextPage } from 'next'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|||||||
@ -130,6 +130,7 @@ export interface TokenRegister {
|
|||||||
email: string
|
email: string
|
||||||
username: string
|
username: string
|
||||||
discriminator: string
|
discriminator: string
|
||||||
|
verified: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DiscordUserInfo {
|
export interface DiscordUserInfo {
|
||||||
|
|||||||
@ -324,14 +324,22 @@ async function getDiscordUser(id: string):Promise<DiscordUser> {
|
|||||||
return DiscordBot.users.cache.get(id) ?? await DiscordBot.users.fetch(id, false, true).then(u => u.toJSON()).catch(()=>null)
|
return DiscordBot.users.cache.get(id) ?? await DiscordBot.users.fetch(id, false, true).then(u => u.toJSON()).catch(()=>null)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function assignToken(info: TokenRegister):Promise<string> {
|
/**
|
||||||
let token = await knex('users').select(['token']).where({ id: info.id })
|
*
|
||||||
|
* @param info
|
||||||
|
* @returns 1 - UnVerified
|
||||||
|
* @returns 2 - Blocked
|
||||||
|
*/
|
||||||
|
async function assignToken(info: TokenRegister):Promise<string|1|2> {
|
||||||
|
let token = await knex('users').select(['token', 'perm']).where({ id: info.id })
|
||||||
let t: string
|
let t: string
|
||||||
|
if(!info.verified) return 1
|
||||||
if(token.length === 0) {
|
if(token.length === 0) {
|
||||||
t = sign({ id: info.id }, { expiresIn: '30d' })
|
t = sign({ id: info.id }, { expiresIn: '30d' })
|
||||||
await knex('users').insert({ token: t, date: Math.round(Number(new Date()) / 1000), id: info.id, email: info.email, tag: info.discriminator, username: info.username, discord: sign({ access_token: info.access_token, expires_in: info.expires_in, refresh_token: info.refresh_token }) })
|
await knex('users').insert({ token: t, date: Math.round(Number(new Date()) / 1000), id: info.id, email: info.email, tag: info.discriminator, username: info.username, discord: sign({ access_token: info.access_token, expires_in: info.expires_in, refresh_token: info.refresh_token }) })
|
||||||
token = await knex('users').select(['token']).where({ id: info.id })
|
token = await knex('users').select(['token']).where({ id: info.id })
|
||||||
} else await knex('users').update({ email: info.email, tag: info.discriminator, username: info.username, discord: sign({ access_token: info.access_token, expires_in: info.expires_in, refresh_token: info.refresh_token }) }).where({ id: info.id })
|
} else await knex('users').update({ email: info.email, tag: info.discriminator, username: info.username, discord: sign({ access_token: info.access_token, expires_in: info.expires_in, refresh_token: info.refresh_token }) }).where({ id: info.id })
|
||||||
|
if(token[0].perm !== 'user') return 2
|
||||||
if(!verify(token[0]?.token ?? '')) {
|
if(!verify(token[0]?.token ?? '')) {
|
||||||
t = sign({ id: info.id }, { expiresIn: '30d' })
|
t = sign({ id: info.id }, { expiresIn: '30d' })
|
||||||
await knex('users').update({ token: t }).where({ id: info.id })
|
await knex('users').update({ token: t }).where({ id: info.id })
|
||||||
|
|||||||
@ -7931,6 +7931,11 @@ re2@^1.15.9:
|
|||||||
nan "^2.14.2"
|
nan "^2.14.2"
|
||||||
node-gyp "^7.1.2"
|
node-gyp "^7.1.2"
|
||||||
|
|
||||||
|
react-adsense@0.1.0:
|
||||||
|
version "0.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-adsense/-/react-adsense-0.1.0.tgz#f170007a9ab05ee2cd1c915cdc9788624658e3c1"
|
||||||
|
integrity sha512-VzGMH9qA7bBKAveK1joFWphhB7e2Y1ToSGzUa8b7eit3+VSkg/2MSvKxe5d/r4mcmkOHu6CHNJW0nn6RQC3IZA==
|
||||||
|
|
||||||
react-dom@17.0.2:
|
react-dom@17.0.2:
|
||||||
version "17.0.2"
|
version "17.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23"
|
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user