kopia lustrzana https://github.com/cloudflare/wildebeest
subscription: make policy optional
rodzic
c353bca4ff
commit
d997d0ca06
|
@ -26,7 +26,7 @@ export interface CreateRequest {
|
||||||
admin_sign_up?: boolean
|
admin_sign_up?: boolean
|
||||||
admin_report?: boolean
|
admin_report?: boolean
|
||||||
}
|
}
|
||||||
policy: string
|
policy?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ export async function createSubscription(
|
||||||
req.data.alerts.update === false ? 0 : 1,
|
req.data.alerts.update === false ? 0 : 1,
|
||||||
req.data.alerts.admin_sign_up === false ? 0 : 1,
|
req.data.alerts.admin_sign_up === false ? 0 : 1,
|
||||||
req.data.alerts.admin_report === false ? 0 : 1,
|
req.data.alerts.admin_report === false ? 0 : 1,
|
||||||
req.data.policy
|
req.data.policy ?? 'all'
|
||||||
)
|
)
|
||||||
.first<any>()
|
.first<any>()
|
||||||
return subscriptionFromRow(row)
|
return subscriptionFromRow(row)
|
||||||
|
|
|
@ -79,7 +79,6 @@ describe('Mastodon APIs', () => {
|
||||||
poll: false,
|
poll: false,
|
||||||
status: true,
|
status: true,
|
||||||
},
|
},
|
||||||
policy: 'all',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const req = new Request('https://example.com', {
|
const req = new Request('https://example.com', {
|
||||||
|
@ -94,6 +93,7 @@ describe('Mastodon APIs', () => {
|
||||||
assert.equal(out.alerts.mention, true)
|
assert.equal(out.alerts.mention, true)
|
||||||
assert.equal(out.alerts.status, true) // default to true
|
assert.equal(out.alerts.status, true) // default to true
|
||||||
assert.equal(out.alerts.poll, false)
|
assert.equal(out.alerts.poll, false)
|
||||||
|
assert.equal(out.policy, 'all') // default policy
|
||||||
|
|
||||||
const row: any = await db.prepare('SELECT * FROM subscriptions').first()
|
const row: any = await db.prepare('SELECT * FROM subscriptions').first()
|
||||||
assert.equal(row.actor_id, connectedActor.id.toString())
|
assert.equal(row.actor_id, connectedActor.id.toString())
|
||||||
|
@ -102,6 +102,7 @@ describe('Mastodon APIs', () => {
|
||||||
assert.equal(row.alert_poll, 0)
|
assert.equal(row.alert_poll, 0)
|
||||||
assert.equal(row.alert_mention, 1)
|
assert.equal(row.alert_mention, 1)
|
||||||
assert.equal(row.alert_status, 1) // default to true
|
assert.equal(row.alert_status, 1) // default to true
|
||||||
|
assert.equal(row.policy, 'all') // default policy
|
||||||
})
|
})
|
||||||
|
|
||||||
test('create subscriptions only creates one', async () => {
|
test('create subscriptions only creates one', async () => {
|
||||||
|
|
Ładowanie…
Reference in New Issue