fix(subscribe): provide toC allow_type
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -18,4 +18,15 @@ describe('test topic client', () => {
|
||||
const data = await client.subscribe.unsubscribe('foo@example.com', 'token')
|
||||
expect(data).toEqual(mocked)
|
||||
})
|
||||
|
||||
test('GET /subscribe/status', async () => {
|
||||
const mocked = mockResponse('/subscribe/status', {
|
||||
enable: true,
|
||||
bit_map: { post_c: 1, note_c: 2, say_c: 4, recently_c: 8, all: 15 },
|
||||
allow_bits: [2, 1],
|
||||
allow_types: ['note_c', 'post_c'],
|
||||
})
|
||||
const data = await client.subscribe.check()
|
||||
expect(data).toEqual(camelcaseKeys(mocked, { deep: true }))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -34,7 +34,8 @@ export class SubscribeController<ResponseWrapper> implements IController {
|
||||
return this.proxy.status.get<{
|
||||
enable: boolean
|
||||
bitMap: Record<SubscribeType, number>
|
||||
allowTypes: number[]
|
||||
allowBits: number[]
|
||||
allowTypes: SubscribeType[]
|
||||
}>()
|
||||
}
|
||||
|
||||
|
||||
4
paw.paw
4
paw.paw
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:308902dc0ba16450fdc2ba34764f89051f63471fe9ca95099b6730ca8e5e2f4a
|
||||
size 101442
|
||||
oid sha256:92c5523d93dee059e54c5056dc000fc3162aee6ec2398ffb2a354f3f980efa4c
|
||||
size 102593
|
||||
|
||||
@@ -5,11 +5,7 @@ import { Auth } from '~/common/decorators/auth.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorators/http.decorator'
|
||||
import { PagerDto } from '~/shared/dto/pager.dto'
|
||||
|
||||
import {
|
||||
SubscribeNoteCreateBit,
|
||||
SubscribePostCreateBit,
|
||||
SubscribeTypeToBitMap,
|
||||
} from './subscribe.constant'
|
||||
import { SubscribeTypeToBitMap } from './subscribe.constant'
|
||||
import { CancelSubscribeDto, SubscribeDto } from './subscribe.dto'
|
||||
import { SubscribeService } from './subscribe.service'
|
||||
|
||||
@@ -21,11 +17,13 @@ export class SubscribeController {
|
||||
// 检查特征是否开启
|
||||
@HTTPDecorators.Bypass
|
||||
async checkStatus() {
|
||||
const allow_types = ['note_c', 'post_c']
|
||||
return {
|
||||
enable: await this.service.checkEnable(),
|
||||
bit_map: SubscribeTypeToBitMap,
|
||||
// TODO move to service
|
||||
allow_types: [SubscribeNoteCreateBit, SubscribePostCreateBit],
|
||||
allow_bits: allow_types.map((t) => SubscribeTypeToBitMap[t]),
|
||||
allow_types,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user