Dwayne Harris 5 years ago
parent
commit
c87b000d44
  1. 11
      src/plugins/api/apps.ts
  2. 13
      src/plugins/api/authentication.ts
  3. 9
      src/plugins/api/users.ts
  4. 16
      src/schemas.ts
  5. 2
      src/types/collections.ts

11
src/plugins/api/apps.ts

@ -66,6 +66,7 @@ function appsRoute(server: FastifyInstance<Server, IncomingMessage, ServerRespon
a.name, a.name,
a.imageUrl, a.imageUrl,
a.coverImageUrl, a.coverImageUrl,
a.iconImageUrl,
a.about, a.about,
a.websiteUrl, a.websiteUrl,
a.companyName a.companyName
@ -138,6 +139,7 @@ function selfAppsRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
a.name, a.name,
a.imageUrl, a.imageUrl,
a.coverImageUrl, a.coverImageUrl,
a.iconImageUrl,
a.about, a.about,
a.websiteUrl, a.websiteUrl,
a.companyName a.companyName
@ -166,6 +168,7 @@ function createRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name: string name: string
imageUrl?: string imageUrl?: string
coverImageUrl?: string coverImageUrl?: string
iconImageUrl?: string
about?: string about?: string
websiteUrl?: string websiteUrl?: string
companyName?: string companyName?: string
@ -187,6 +190,7 @@ function createRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name: { type: 'string' }, name: { type: 'string' },
imageUrl: { type: 'string' }, imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' }, coverImageUrl: { type: 'string' },
iconImageUrl: { type: 'string' },
about: { type: 'string' }, about: { type: 'string' },
websiteUrl: { type: 'string' }, websiteUrl: { type: 'string' },
companyName: { type: 'string' }, companyName: { type: 'string' },
@ -222,6 +226,7 @@ function createRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name, name,
imageUrl, imageUrl,
coverImageUrl, coverImageUrl,
iconImageUrl,
about, about,
websiteUrl, websiteUrl,
companyName, companyName,
@ -244,6 +249,7 @@ function createRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name, name,
imageUrl, imageUrl,
coverImageUrl, coverImageUrl,
iconImageUrl,
about, about,
websiteUrl, websiteUrl,
companyName, companyName,
@ -279,6 +285,7 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name: string name: string
imageUrl?: string imageUrl?: string
coverImageUrl?: string coverImageUrl?: string
iconImageUrl?: string
about?: string about?: string
websiteUrl?: string websiteUrl?: string
companyName?: string companyName?: string
@ -299,6 +306,7 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
version: { type: 'string' }, version: { type: 'string' },
imageUrl: { type: 'string' }, imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' }, coverImageUrl: { type: 'string' },
iconImageUrl: { type: 'string' },
about: { type: 'string' }, about: { type: 'string' },
websiteUrl: { type: 'string' }, websiteUrl: { type: 'string' },
companyName: { type: 'string' }, companyName: { type: 'string' },
@ -327,6 +335,7 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name, name,
imageUrl, imageUrl,
coverImageUrl, coverImageUrl,
iconImageUrl,
about, about,
websiteUrl, websiteUrl,
companyName, companyName,
@ -348,6 +357,7 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name: name || app.name, name: name || app.name,
imageUrl, imageUrl,
coverImageUrl, coverImageUrl,
iconImageUrl,
about, about,
websiteUrl, websiteUrl,
companyName, companyName,
@ -364,6 +374,7 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
name: app.name, name: app.name,
imageUrl: app.imageUrl, imageUrl: app.imageUrl,
coverImageUrl: app.coverImageUrl, coverImageUrl: app.coverImageUrl,
iconImageUrl: app.iconImageUrl,
about: app.about, about: app.about,
websiteUrl: app.websiteUrl, websiteUrl: app.websiteUrl,
companyName: app.companyName, companyName: app.companyName,

13
src/plugins/api/authentication.ts

@ -41,6 +41,8 @@ function registerRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
name: string name: string
email: string email: string
password: string password: string
requiresApproval: boolean
privacy: string
group?: string group?: string
invitation?: string invitation?: string
} }
@ -68,6 +70,11 @@ function registerRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
type: 'string', type: 'string',
minLength: MIN_PASSWORD_LENGTH, minLength: MIN_PASSWORD_LENGTH,
}, },
requiresApproval: { type: 'boolean' },
privacy: {
type: 'string',
enum: ['public', 'group', 'subscribers', 'private'],
},
group: { type: 'string' }, group: { type: 'string' },
invitation: { type: 'string' }, invitation: { type: 'string' },
}, },
@ -82,7 +89,7 @@ function registerRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
server.post<DefaultQuery, DefaultParams, DefaultHeaders, Body>('/api/register', options, async (request, reply) => { server.post<DefaultQuery, DefaultParams, DefaultHeaders, Body>('/api/register', options, async (request, reply) => {
if (!server.database) return serverError(reply) if (!server.database) return serverError(reply)
const { name, email, password, invitation: code } = request.body
const { name, email, password, requiresApproval, privacy, invitation: code } = request.body
const id = normalize(request.body.id) const id = normalize(request.body.id)
const userContainer = containerFor(server.database.client, 'Users') const userContainer = containerFor(server.database.client, 'Users')
@ -163,8 +170,8 @@ function registerRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
subscriberCount: 0, subscriberCount: 0,
subscribedCount: 0, subscribedCount: 0,
pending: userPending, pending: userPending,
requiresApproval: false,
privacy: UserPrivacyType.Public,
requiresApproval,
privacy: privacy as UserPrivacyType,
paid: false, paid: false,
active: true, active: true,
created: Date.now(), created: Date.now(),

9
src/plugins/api/users.ts

@ -120,16 +120,12 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
if (request.body.name) { if (request.body.name) {
const name = request.body.name.trim() const name = request.body.name.trim()
if (name !== '') {
viewer.name = name
}
if (name !== '') viewer.name = name
} }
if (request.body.about) { if (request.body.about) {
const about = request.body.about.trim() const about = request.body.about.trim()
if (about !== '') {
viewer.about = about
}
if (about !== '') viewer.about = about
} }
if (request.body.requiresApproval !== undefined) { if (request.body.requiresApproval !== undefined) {
@ -141,7 +137,6 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp
} }
await viewerItem.replace<User>(viewer) await viewerItem.replace<User>(viewer)
return viewer return viewer
}) })
} }

16
src/schemas.ts

@ -54,6 +54,7 @@ export const appSchema: JSONSchema = {
displayName: { type: 'string' }, displayName: { type: 'string' },
imageUrl: { type: 'string' }, imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' }, coverImageUrl: { type: 'string' },
iconImageUrl: { type: 'string' },
about: { type: 'string' }, about: { type: 'string' },
websiteUrl: { type: 'string' }, websiteUrl: { type: 'string' },
companyName: { type: 'string' }, companyName: { type: 'string' },
@ -81,13 +82,18 @@ export const selfSchema: JSONSchema = {
}, },
}, },
installations: { installations: {
type: 'object',
properties: {
app: appSchema,
settings: { type: 'object' },
created: { type: 'number' },
type: 'array',
items: {
type: 'object',
properties: {
app: appSchema,
settings: { type: 'object' },
created: { type: 'number' },
},
}, },
}, },
requiresApproval: { type: 'boolean' },
privacy: { type: 'string' },
membership: { type: 'string' }, membership: { type: 'string' },
created: { type: 'number' }, created: { type: 'number' },
}, },

2
src/types/collections.ts

@ -317,6 +317,7 @@ export interface AppRevision {
name: string name: string
imageUrl?: string imageUrl?: string
coverImageUrl?: string coverImageUrl?: string
iconImageUrl?: string
about?: string about?: string
websiteUrl?: string websiteUrl?: string
companyName?: string companyName?: string
@ -337,6 +338,7 @@ export interface App {
name: string name: string
imageUrl?: string imageUrl?: string
coverImageUrl?: string coverImageUrl?: string
iconImageUrl?: string
about?: string about?: string
websiteUrl?: string websiteUrl?: string
companyName?: string companyName?: string

Loading…
Cancel
Save