增加一次性群邀请链接和二维码
This commit is contained in:
1 parent
dfeb5bfefa
commit
5ec9c81f90
18 files changed
+727
-14
No files matched your search
@@ -154,6 +154,39 @@ test('群组邀请、授权、成员移除、版本变更与实时提示', { tim
|
||||
assert.deepEqual(unrelated, [])
|
||||
})
|
||||
|
||||
test('群邀请链接可轮换、撤销且只能领取一次', { timeout: 25_000 }, async () => {
|
||||
const [owner, first, second] = await Promise.all([register(), register(), register()])
|
||||
const group = await json('/groups', 'POST', owner.token, { name: '群链接验收' }, 201)
|
||||
const path = '/groups/' + group.id
|
||||
const issue = () => json(path + '/invite-link', 'POST', owner.token, undefined, 201)
|
||||
const redeem = (actor, code) => call('/group-invites/redeem', 'POST', actor.token, { code })
|
||||
assert.equal((await call(path + '/invite-link', 'POST', first.token)).status, 404)
|
||||
const initial = await issue()
|
||||
assert.match(initial.code, /^[A-Za-z0-9_-]{43}$/)
|
||||
assert.ok(Date.parse(initial.expiresAt) - Date.now() > 23 * 60 * 60 * 1000)
|
||||
const current = await issue()
|
||||
assert.equal((await redeem(first, initial.code)).status, 404)
|
||||
assert.equal((await redeem(owner, current.code)).status, 409)
|
||||
const results = await Promise.all([redeem(first, current.code), redeem(second, current.code)])
|
||||
assert.deepEqual(results.map((result) => result.status).sort(), [200, 404])
|
||||
const winner = results[0].ok ? first : second
|
||||
const other = results[0].ok ? second : first
|
||||
assert.deepEqual(await results.find((result) => result.ok).json(), { groupId: group.id })
|
||||
const pending = await json(path, 'GET', winner.token)
|
||||
assert.equal(pending.state, 'invited')
|
||||
assert.deepEqual(pending.members, [])
|
||||
assert.equal((await call(path + '/messages', 'GET', winner.token)).status, 404)
|
||||
assert.equal((await call(path, 'POST', winner.token, { action: 'accept' })).status, 204)
|
||||
assert.equal((await json(path, 'GET', winner.token)).membershipVersion, '2')
|
||||
assert.equal((await call(path + '/invite-link', 'POST', winner.token)).status, 409)
|
||||
const revoked = await issue()
|
||||
assert.equal((await call(path + '/invite-link', 'DELETE', owner.token)).status, 204)
|
||||
assert.equal((await redeem(other, revoked.code)).status, 404)
|
||||
const previousOwner = await issue()
|
||||
assert.equal((await call(path, 'POST', owner.token, { action: 'transfer', target: winner.user.id })).status, 204)
|
||||
assert.equal((await redeem(other, previousOwner.code)).status, 404)
|
||||
})
|
||||
|
||||
test('群密文和实时提示只投递到名单设备,移除或撤销阻断旧世代', { timeout: 25_000 }, async (t) => {
|
||||
const enroll = async () => {
|
||||
const keys = generateKeyPairSync('ed25519')
|
||||
|
||||
Reference in new issue
Block a user