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

13
src/plugins/api/authentication.ts

@ -41,6 +41,8 @@ function registerRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
name: string
email: string
password: string
requiresApproval: boolean
privacy: string
group?: string
invitation?: string
}
@ -68,6 +70,11 @@ function registerRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
type: 'string',
minLength: MIN_PASSWORD_LENGTH,
},
requiresApproval: { type: 'boolean' },
privacy: {
type: 'string',
enum: ['public', 'group', 'subscribers', 'private'],
},
group: { 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) => {
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 userContainer = containerFor(server.database.client, 'Users')
@ -163,8 +170,8 @@ function registerRoute(server: FastifyInstance<Server, IncomingMessage, ServerRe
subscriberCount: 0,
subscribedCount: 0,
pending: userPending,
requiresApproval: false,
privacy: UserPrivacyType.Public,
requiresApproval,
privacy: privacy as UserPrivacyType,
paid: false,
active: true,
created: Date.now(),

9
src/plugins/api/users.ts

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

16
src/schemas.ts

@ -54,6 +54,7 @@ export const appSchema: JSONSchema = {
displayName: { type: 'string' },
imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' },
iconImageUrl: { type: 'string' },
about: { type: 'string' },
websiteUrl: { type: 'string' },
companyName: { type: 'string' },
@ -81,13 +82,18 @@ export const selfSchema: JSONSchema = {
},
},
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' },
created: { type: 'number' },
},

2
src/types/collections.ts

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

Loading…
Cancel
Save