@@ -1,3 +0,0 @@
|
||||
export function isForbidden({ expires, forbidden }: { expires: Date; forbidden?: boolean }) {
|
||||
return forbidden || new Date(expires) < new Date();
|
||||
}
|
||||
@@ -16,17 +16,13 @@ const InvitationSchema = new Schema({
|
||||
required: true
|
||||
},
|
||||
usedTimesLimit: {
|
||||
type: Number
|
||||
},
|
||||
forbidden: {
|
||||
type: Boolean
|
||||
},
|
||||
expires: {
|
||||
type: Date
|
||||
},
|
||||
description: {
|
||||
type: String
|
||||
type: Number,
|
||||
default: 1,
|
||||
enum: [1, -1]
|
||||
},
|
||||
forbidden: Boolean,
|
||||
expires: Date,
|
||||
description: String,
|
||||
members: {
|
||||
type: [String],
|
||||
default: []
|
||||
@@ -40,10 +36,9 @@ InvitationSchema.virtual('team', {
|
||||
justOne: true
|
||||
});
|
||||
|
||||
InvitationSchema.index({ expires: 1 }, { expireAfterSeconds: 30 * 24 * 60 * 60 });
|
||||
|
||||
try {
|
||||
InvitationSchema.index({ teamId: 1 }, { background: true });
|
||||
InvitationSchema.index({ teamId: 1 });
|
||||
InvitationSchema.index({ expires: 1 }, { expireAfterSeconds: 30 * 24 * 60 * 60 });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export type InvitationLinkExpiresType = '30m' | '7d' | '1y';
|
||||
export type InvitationLinkCreateType = {
|
||||
description: string;
|
||||
expires: InvitationLinkExpiresType;
|
||||
usedTimesLimit: number;
|
||||
usedTimesLimit: 1 | -1;
|
||||
};
|
||||
export type InvitationLinkUpdateType = Partial<
|
||||
Omit<InvitationSchemaType, 'members' | 'teamId' | '_id'>
|
||||
|
||||
Reference in New Issue
Block a user