@duvdu-v1/duvdu 1.1.174 → 1.1.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/middlewares/auth.middleware.js +3 -3
- package/build/middlewares/check-required-files.middleware.js +4 -1
- package/build/middlewares/global-validator.middleware.js +1 -1
- package/build/middlewares/upload-project-media.middleware.js +5 -1
- package/build/models/Review.model.js +2 -2
- package/build/models/User.model.js +8 -5
- package/build/models/all-contracts.model.js +1 -1
- package/build/models/category.model.js +2 -2
- package/build/models/coupon.model.js +7 -2
- package/build/models/follow.model.js +1 -1
- package/build/models/messages.model.js +19 -14
- package/build/models/notification.model.js +1 -1
- package/build/models/producer.model.js +9 -4
- package/build/models/projectViews.model.js +1 -1
- package/build/models/ranks.model.js +1 -1
- package/build/models/settings.model.js +5 -3
- package/build/models/teamProject.model.js +26 -24
- package/build/models/userSession.model.js +1 -1
- package/build/services/category.service.js +9 -2
- package/build/services/rank.service.js +6 -2
- package/build/types/Permissions.js +5 -9
- package/build/types/User.d.ts +4 -6
- package/build/types/notification_details.js +9 -9
- package/build/utils/generateToken.js +1 -1
- package/package.json +1 -1
|
@@ -61,9 +61,9 @@ const isauthenticated = (req, res, next) => __awaiter(void 0, void 0, void 0, fu
|
|
|
61
61
|
_id: payload.id,
|
|
62
62
|
refreshTokens: {
|
|
63
63
|
$elemMatch: {
|
|
64
|
-
token: req.session.refresh
|
|
65
|
-
}
|
|
66
|
-
}
|
|
64
|
+
token: req.session.refresh,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
67
|
});
|
|
68
68
|
if (!user)
|
|
69
69
|
return res.status(423).json({ message: 'token expired' });
|
|
@@ -14,7 +14,10 @@ const checkRequiredFields = (options) => ((req, res, next) => {
|
|
|
14
14
|
}
|
|
15
15
|
else if (options.fields) {
|
|
16
16
|
if (!req.files)
|
|
17
|
-
return next(new bad_request_error_1.BadRequestError({
|
|
17
|
+
return next(new bad_request_error_1.BadRequestError({
|
|
18
|
+
en: `${options.fields.join(' ')} is required`,
|
|
19
|
+
ar: `${options.fields.join(' ')} مطلوب`,
|
|
20
|
+
}, req.lang));
|
|
18
21
|
for (const field of options.fields) {
|
|
19
22
|
if (!((_a = req.files) === null || _a === void 0 ? void 0 : _a[field]))
|
|
20
23
|
return next(new bad_request_error_1.BadRequestError({ en: `${field} is required`, ar: `${field} مطلوب` }));
|
|
@@ -28,7 +28,7 @@ const globalValidatorMiddleware = (req, res, next) => {
|
|
|
28
28
|
if (!errors.isEmpty()) {
|
|
29
29
|
const lang = req.lang;
|
|
30
30
|
const language = loadLanguageFile(lang);
|
|
31
|
-
const translatedErrors = errors.array().map(error => (Object.assign(Object.assign({}, error), { msg: language[error.msg] || error.msg })));
|
|
31
|
+
const translatedErrors = errors.array().map((error) => (Object.assign(Object.assign({}, error), { msg: language[error.msg] || error.msg })));
|
|
32
32
|
return next(new validation_error_1.ValidationError(translatedErrors));
|
|
33
33
|
}
|
|
34
34
|
req.body = (0, express_validator_1.matchedData)(req, { locations: ['body'] });
|
|
@@ -17,7 +17,11 @@ const uploadProjectMedia = (folder) => (0, multer_1.default)({
|
|
|
17
17
|
}),
|
|
18
18
|
limits: { fileSize: 100 * 1024 * 1024 },
|
|
19
19
|
fileFilter(req, file, callback) {
|
|
20
|
-
if (file.mimetype.startsWith('image') ||
|
|
20
|
+
if (file.mimetype.startsWith('image') ||
|
|
21
|
+
file.mimetype.startsWith('video') ||
|
|
22
|
+
file.mimetype === 'application/pdf' ||
|
|
23
|
+
file.mimetype === 'audio/mpeg' ||
|
|
24
|
+
file.mimetype === 'audio/wav')
|
|
21
25
|
return callback(null, true);
|
|
22
26
|
return callback(new bad_request_error_1.BadRequestError('invalid file format'));
|
|
23
27
|
},
|
|
@@ -9,7 +9,7 @@ exports.ProjectReview = (0, mongoose_1.model)(model_names_1.MODELS.projectReview
|
|
|
9
9
|
project: { type: mongoose_1.Schema.Types.ObjectId },
|
|
10
10
|
cycle: { type: String, enum: cycles_1.CYCLES },
|
|
11
11
|
rate: { type: Number, default: 0 },
|
|
12
|
-
comment: { type: String, default: null }
|
|
12
|
+
comment: { type: String, default: null },
|
|
13
13
|
}, { timestamps: true, collection: model_names_1.MODELS.projectReview }));
|
|
14
14
|
exports.ContractReview = (0, mongoose_1.model)(model_names_1.MODELS.contractReview, new mongoose_1.Schema({
|
|
15
15
|
sp: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
@@ -17,5 +17,5 @@ exports.ContractReview = (0, mongoose_1.model)(model_names_1.MODELS.contractRevi
|
|
|
17
17
|
contract: { type: mongoose_1.Schema.Types.ObjectId },
|
|
18
18
|
cycle: { type: String, enum: cycles_1.CYCLES },
|
|
19
19
|
rate: { type: Number, default: 0 },
|
|
20
|
-
comment: { type: String, default: null }
|
|
20
|
+
comment: { type: String, default: null },
|
|
21
21
|
}, { timestamps: true, collection: model_names_1.MODELS.contractReview }));
|
|
@@ -29,14 +29,15 @@ const userSchema = new mongoose_1.Schema({
|
|
|
29
29
|
refreshTokens: [
|
|
30
30
|
{
|
|
31
31
|
token: { type: String, default: null },
|
|
32
|
-
|
|
33
|
-
clientType: { type: String, default: null },
|
|
34
|
-
userAgent: { type: String, default: null },
|
|
32
|
+
deviceId: { type: String, default: null },
|
|
35
33
|
},
|
|
36
34
|
],
|
|
37
35
|
profileImage: { type: String, default: 'defaults/profile.jpg' },
|
|
38
36
|
coverImage: { type: String, default: null },
|
|
39
|
-
location: {
|
|
37
|
+
location: {
|
|
38
|
+
type: { type: String, default: 'Point' },
|
|
39
|
+
coordinates: { type: [Number], default: [31.2357, 30.0444] },
|
|
40
|
+
},
|
|
40
41
|
category: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.category, default: null },
|
|
41
42
|
acceptedProjectsCounter: { type: Number, default: 0 },
|
|
42
43
|
profileViews: { type: Number, default: 0 },
|
|
@@ -80,7 +81,9 @@ const userSchema = new mongoose_1.Schema({
|
|
|
80
81
|
ret.profileImage = process.env.BUCKET_HOST + '/' + ret.profileImage;
|
|
81
82
|
},
|
|
82
83
|
},
|
|
83
|
-
})
|
|
84
|
+
})
|
|
85
|
+
.index({ name: 'text' })
|
|
86
|
+
.index({ location: '2dsphere' });
|
|
84
87
|
userSchema.pre('save', function (next) {
|
|
85
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
89
|
if (this.isModified('acceptedProjectsCounter'))
|
|
@@ -9,7 +9,7 @@ exports.Contracts = (0, mongoose_1.model)(model_names_1.MODELS.allContracts, new
|
|
|
9
9
|
contract: { type: mongoose_1.Schema.Types.ObjectId, refPath: 'ref' },
|
|
10
10
|
ref: String,
|
|
11
11
|
cycle: { type: String, default: null },
|
|
12
|
-
coupons: [{ type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.coupon }]
|
|
12
|
+
coupons: [{ type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.coupon }],
|
|
13
13
|
}, { timestamps: true, collection: model_names_1.MODELS.allContracts }));
|
|
14
14
|
exports.ContractReports = (0, mongoose_1.model)(model_names_1.MODELS.contractReports, new mongoose_1.Schema({
|
|
15
15
|
reporter: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
@@ -39,7 +39,7 @@ const categorySchema = new mongoose_1.default.Schema({
|
|
|
39
39
|
default: true,
|
|
40
40
|
},
|
|
41
41
|
trend: { type: Boolean, default: false },
|
|
42
|
-
media: { type: String, enum: ['image', 'video', 'audio'] }
|
|
42
|
+
media: { type: String, enum: ['image', 'video', 'audio'] },
|
|
43
43
|
}, {
|
|
44
44
|
timestamps: true,
|
|
45
45
|
collection: model_names_1.MODELS.category,
|
|
@@ -55,6 +55,6 @@ categorySchema.set('toJSON', {
|
|
|
55
55
|
if (ret.image)
|
|
56
56
|
ret.image = process.env.BUCKET_HOST + '/' + ret.image;
|
|
57
57
|
return ret;
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
59
|
});
|
|
60
60
|
exports.Categories = mongoose_1.default.model(model_names_1.MODELS.category, categorySchema);
|
|
@@ -6,7 +6,12 @@ const model_names_1 = require("../types/model-names");
|
|
|
6
6
|
exports.Coupon = (0, mongoose_1.model)(model_names_1.MODELS.coupon, new mongoose_1.Schema({
|
|
7
7
|
title: { en: { type: String, default: null }, ar: { type: String, default: null } },
|
|
8
8
|
promoCode: { type: String, unique: true, sparse: true },
|
|
9
|
-
users: [
|
|
9
|
+
users: [
|
|
10
|
+
{
|
|
11
|
+
user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
12
|
+
count: { type: Number, default: 0 },
|
|
13
|
+
},
|
|
14
|
+
],
|
|
10
15
|
couponCount: { type: Number, default: 1 },
|
|
11
16
|
couponCountAvaliable: { type: Number, default: 0 },
|
|
12
17
|
userCount: { type: Number, default: 1 },
|
|
@@ -14,5 +19,5 @@ exports.Coupon = (0, mongoose_1.model)(model_names_1.MODELS.coupon, new mongoose
|
|
|
14
19
|
percentage: { type: Number, default: null },
|
|
15
20
|
expired: { type: Boolean, default: false },
|
|
16
21
|
start: Date,
|
|
17
|
-
end: Date
|
|
22
|
+
end: Date,
|
|
18
23
|
}, { timestamps: true, collection: model_names_1.MODELS.coupon }));
|
|
@@ -5,5 +5,5 @@ const mongoose_1 = require("mongoose");
|
|
|
5
5
|
const model_names_1 = require("../types/model-names");
|
|
6
6
|
exports.Follow = (0, mongoose_1.model)(model_names_1.MODELS.follow, new mongoose_1.Schema({
|
|
7
7
|
follower: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
8
|
-
following: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user }
|
|
8
|
+
following: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
|
|
9
9
|
}, { timestamps: true, collection: model_names_1.MODELS.follow }));
|
|
@@ -11,43 +11,48 @@ exports.Message = (0, mongoose_1.model)(model_names_1.MODELS.messages, new mongo
|
|
|
11
11
|
sender: {
|
|
12
12
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
13
13
|
ref: model_names_1.MODELS.user,
|
|
14
|
-
required: true
|
|
14
|
+
required: true,
|
|
15
15
|
},
|
|
16
16
|
receiver: {
|
|
17
17
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
18
18
|
ref: model_names_1.MODELS.user,
|
|
19
|
-
required: true
|
|
19
|
+
required: true,
|
|
20
20
|
},
|
|
21
21
|
content: {
|
|
22
22
|
type: String,
|
|
23
|
-
default: null
|
|
23
|
+
default: null,
|
|
24
24
|
},
|
|
25
25
|
reactions: [reactionSchema],
|
|
26
|
-
media: [
|
|
26
|
+
media: [
|
|
27
|
+
{
|
|
27
28
|
type: {
|
|
28
29
|
type: String,
|
|
29
|
-
default: null
|
|
30
|
+
default: null,
|
|
30
31
|
},
|
|
31
32
|
url: {
|
|
32
33
|
type: String,
|
|
33
|
-
default: null
|
|
34
|
+
default: null,
|
|
34
35
|
},
|
|
35
|
-
}
|
|
36
|
+
},
|
|
37
|
+
],
|
|
36
38
|
watched: {
|
|
37
39
|
type: Boolean,
|
|
38
|
-
default: false
|
|
40
|
+
default: false,
|
|
39
41
|
},
|
|
40
42
|
updated: {
|
|
41
43
|
type: Boolean,
|
|
42
|
-
default: false
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
}, {
|
|
47
|
+
timestamps: true,
|
|
48
|
+
collection: model_names_1.MODELS.messages,
|
|
49
|
+
toJSON: {
|
|
45
50
|
transform(doc, ret) {
|
|
46
51
|
var _a;
|
|
47
52
|
if ((_a = ret.media) === null || _a === void 0 ? void 0 : _a.url)
|
|
48
53
|
ret.media.url = process.env.BUCKET_HOST + '/' + ret.media.url;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
51
56
|
}));
|
|
52
57
|
exports.Message.schema.set('toJSON', {
|
|
53
58
|
transform: function (doc, ret) {
|
|
@@ -56,5 +61,5 @@ exports.Message.schema.set('toJSON', {
|
|
|
56
61
|
ret.media.url = process.env.BUCKET_HOST + '/' + ret.media.url;
|
|
57
62
|
}
|
|
58
63
|
return ret;
|
|
59
|
-
}
|
|
64
|
+
},
|
|
60
65
|
});
|
|
@@ -8,7 +8,7 @@ exports.Notification = (0, mongoose_1.model)(model_names_1.MODELS.notifications,
|
|
|
8
8
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
9
9
|
ref: model_names_1.MODELS.user,
|
|
10
10
|
// required:true
|
|
11
|
-
default: null
|
|
11
|
+
default: null,
|
|
12
12
|
},
|
|
13
13
|
targetUser: {
|
|
14
14
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
@@ -6,14 +6,19 @@ const model_names_1 = require("../types/model-names");
|
|
|
6
6
|
exports.Producer = (0, mongoose_1.model)(model_names_1.MODELS.producer, new mongoose_1.Schema({
|
|
7
7
|
user: {
|
|
8
8
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
9
|
-
ref: model_names_1.MODELS.user
|
|
9
|
+
ref: model_names_1.MODELS.user,
|
|
10
10
|
},
|
|
11
11
|
category: {
|
|
12
12
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
13
|
-
ref: model_names_1.MODELS.category
|
|
13
|
+
ref: model_names_1.MODELS.category,
|
|
14
14
|
},
|
|
15
|
-
subCategories: [
|
|
15
|
+
subCategories: [
|
|
16
|
+
{
|
|
17
|
+
title: { ar: { type: String, default: null }, en: { type: String, default: null } },
|
|
18
|
+
tags: [{ en: { type: String, default: null }, ar: { type: String, default: null } }],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
16
21
|
minBudget: { type: Number, default: null },
|
|
17
22
|
maxBudget: { type: Number, default: null },
|
|
18
|
-
searchKeywords: [String]
|
|
23
|
+
searchKeywords: [String],
|
|
19
24
|
}, { timestamps: true, collection: model_names_1.MODELS.producer }));
|
|
@@ -13,7 +13,7 @@ const projectViewSchema = new mongoose_1.Schema({
|
|
|
13
13
|
project: { type: mongoose_1.Schema.Types.ObjectId, refPath: 'ref' },
|
|
14
14
|
ref: { type: String, enum: RefModels },
|
|
15
15
|
count: { type: Number, default: 1 },
|
|
16
|
-
date: { type: Date, default: Date.now }
|
|
16
|
+
date: { type: Date, default: Date.now },
|
|
17
17
|
}, { timestamps: true, collection: model_names_1.MODELS.projectsViews });
|
|
18
18
|
projectViewSchema.index({ project: 1, ref: 1, date: 1 }, { unique: true });
|
|
19
19
|
exports.ProjectView = (0, mongoose_1.model)(model_names_1.MODELS.projectsViews, projectViewSchema);
|
|
@@ -6,5 +6,5 @@ const model_names_1 = require("../types/model-names");
|
|
|
6
6
|
exports.Rank = (0, mongoose_1.model)(model_names_1.MODELS.rank, new mongoose_1.Schema({
|
|
7
7
|
actionCount: { type: Number, unique: true, default: 0 },
|
|
8
8
|
rank: { type: String, unique: true, default: null },
|
|
9
|
-
color: { type: String, default: null }
|
|
9
|
+
color: { type: String, default: null },
|
|
10
10
|
}, { timestamps: true, collection: model_names_1.MODELS.rank }));
|
|
@@ -7,9 +7,11 @@ exports.Setting = (0, mongoose_1.model)(model_names_1.MODELS.setting, new mongoo
|
|
|
7
7
|
expirationTime: [{ time: { type: Number, unique: true } }],
|
|
8
8
|
default_profile: String,
|
|
9
9
|
default_cover: String,
|
|
10
|
-
splash: [
|
|
10
|
+
splash: [
|
|
11
|
+
{
|
|
11
12
|
cover: { type: String, default: null },
|
|
12
13
|
title: { type: String, default: null },
|
|
13
|
-
subTitle: { type: String, default: null }
|
|
14
|
-
}
|
|
14
|
+
subTitle: { type: String, default: null },
|
|
15
|
+
},
|
|
16
|
+
],
|
|
15
17
|
}, { timestamps: true, collection: model_names_1.MODELS.setting }));
|
|
@@ -7,91 +7,93 @@ const UserSchema = new mongoose_1.Schema({
|
|
|
7
7
|
user: {
|
|
8
8
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
9
9
|
ref: model_names_1.MODELS.user,
|
|
10
|
-
required: true
|
|
10
|
+
required: true,
|
|
11
11
|
},
|
|
12
12
|
workHours: {
|
|
13
13
|
type: Number,
|
|
14
14
|
required: true,
|
|
15
|
-
default: null
|
|
15
|
+
default: null,
|
|
16
16
|
},
|
|
17
17
|
totalAmount: {
|
|
18
18
|
type: Number,
|
|
19
19
|
required: true,
|
|
20
|
-
default: null
|
|
20
|
+
default: null,
|
|
21
21
|
},
|
|
22
22
|
status: {
|
|
23
23
|
type: String,
|
|
24
24
|
enum: ['pending', 'rejected', 'accepted'],
|
|
25
25
|
required: true,
|
|
26
|
-
default: 'pending'
|
|
27
|
-
}
|
|
26
|
+
default: 'pending',
|
|
27
|
+
},
|
|
28
28
|
});
|
|
29
29
|
const CreativeSchema = new mongoose_1.Schema({
|
|
30
30
|
category: {
|
|
31
31
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
32
32
|
required: true,
|
|
33
|
-
ref: model_names_1.MODELS.category
|
|
33
|
+
ref: model_names_1.MODELS.category,
|
|
34
34
|
},
|
|
35
|
-
users: [UserSchema]
|
|
35
|
+
users: [UserSchema],
|
|
36
36
|
});
|
|
37
37
|
exports.TeamProject = (0, mongoose_1.model)(model_names_1.MODELS.teamProject, new mongoose_1.Schema({
|
|
38
38
|
user: {
|
|
39
39
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
40
|
-
ref: model_names_1.MODELS.user
|
|
40
|
+
ref: model_names_1.MODELS.user,
|
|
41
41
|
},
|
|
42
42
|
cover: {
|
|
43
43
|
type: String,
|
|
44
|
-
default: null
|
|
44
|
+
default: null,
|
|
45
45
|
},
|
|
46
46
|
title: {
|
|
47
47
|
type: String,
|
|
48
|
-
default: null
|
|
48
|
+
default: null,
|
|
49
49
|
},
|
|
50
50
|
budget: {
|
|
51
51
|
type: Number,
|
|
52
|
-
default: null
|
|
52
|
+
default: null,
|
|
53
53
|
},
|
|
54
54
|
desc: {
|
|
55
55
|
type: String,
|
|
56
|
-
default: null
|
|
56
|
+
default: null,
|
|
57
57
|
},
|
|
58
58
|
location: {
|
|
59
59
|
lat: {
|
|
60
60
|
type: Number,
|
|
61
|
-
default: null
|
|
61
|
+
default: null,
|
|
62
62
|
},
|
|
63
63
|
lng: {
|
|
64
64
|
type: Number,
|
|
65
|
-
default: null
|
|
66
|
-
}
|
|
65
|
+
default: null,
|
|
66
|
+
},
|
|
67
67
|
},
|
|
68
68
|
address: {
|
|
69
69
|
type: String,
|
|
70
|
-
default: null
|
|
70
|
+
default: null,
|
|
71
71
|
},
|
|
72
72
|
attachments: {
|
|
73
73
|
type: [String],
|
|
74
|
-
default: null
|
|
74
|
+
default: null,
|
|
75
75
|
},
|
|
76
76
|
shootingDays: {
|
|
77
77
|
type: Number,
|
|
78
|
-
default: null
|
|
78
|
+
default: null,
|
|
79
79
|
},
|
|
80
80
|
startDate: {
|
|
81
81
|
type: Date,
|
|
82
|
-
default: null
|
|
82
|
+
default: null,
|
|
83
83
|
},
|
|
84
84
|
status: {
|
|
85
85
|
type: String,
|
|
86
86
|
enum: ['pending', 'completed'],
|
|
87
|
-
default: 'pending'
|
|
87
|
+
default: 'pending',
|
|
88
88
|
},
|
|
89
89
|
creatives: [CreativeSchema],
|
|
90
90
|
isDeleted: {
|
|
91
91
|
type: Boolean,
|
|
92
|
-
default: false
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
92
|
+
default: false,
|
|
93
|
+
},
|
|
94
|
+
}, {
|
|
95
|
+
timestamps: true,
|
|
96
|
+
collection: model_names_1.MODELS.teamProject,
|
|
95
97
|
toJSON: {
|
|
96
98
|
transform(doc, ret) {
|
|
97
99
|
if (ret.cover)
|
|
@@ -99,5 +101,5 @@ exports.TeamProject = (0, mongoose_1.model)(model_names_1.MODELS.teamProject, ne
|
|
|
99
101
|
if (ret.attachments)
|
|
100
102
|
ret.attachments = ret.attachments.map((el) => process.env.BUCKET_HOST + '/' + el);
|
|
101
103
|
},
|
|
102
|
-
}
|
|
104
|
+
},
|
|
103
105
|
}));
|
|
@@ -9,5 +9,5 @@ exports.userSession = (0, mongoose_1.model)(model_names_1.MODELS.userSession, ne
|
|
|
9
9
|
accessToken: { type: String, default: null },
|
|
10
10
|
refreshToken: { type: String, default: null },
|
|
11
11
|
userAgent: { type: String, default: null },
|
|
12
|
-
clientType: { type: String, enum: ['web', 'mobile'], default: null }
|
|
12
|
+
clientType: { type: String, enum: ['web', 'mobile'], default: null },
|
|
13
13
|
}, { timestamps: true }));
|
|
@@ -30,12 +30,19 @@ function filterTagsForCategory(categoryId, subcategoryId, tagIds, cycle, lang) {
|
|
|
30
30
|
if (!subcategoryFound)
|
|
31
31
|
throw new bad_request_error_1.BadRequestError({ en: 'Invalid subcategory', ar: 'فئة فرعية غير صالحة' }, lang);
|
|
32
32
|
if (!subcategoryFound.tags || !Array.isArray(subcategoryFound.tags)) {
|
|
33
|
-
throw new bad_request_error_1.BadRequestError({
|
|
33
|
+
throw new bad_request_error_1.BadRequestError({
|
|
34
|
+
en: 'Subcategory does not contain valid tags',
|
|
35
|
+
ar: 'الفئة الفرعية لا تحتوي على علامات صالحة',
|
|
36
|
+
}, lang);
|
|
34
37
|
}
|
|
35
38
|
const filteredTags = subcategoryFound.tags.filter((tag) => tagIds.includes(tag._id.toString()));
|
|
36
39
|
if (filteredTags.length !== tagIds.length)
|
|
37
40
|
throw new bad_request_error_1.BadRequestError({ en: 'Invalid tags', ar: 'العلامات غير صالحة' }, lang);
|
|
38
|
-
return {
|
|
41
|
+
return {
|
|
42
|
+
subCategoryTitle: subcategoryFound.title,
|
|
43
|
+
filteredTags,
|
|
44
|
+
media: category.media ? category.media : undefined,
|
|
45
|
+
};
|
|
39
46
|
});
|
|
40
47
|
}
|
|
41
48
|
exports.filterTagsForCategory = filterTagsForCategory;
|
|
@@ -12,8 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.updateRankForUser = void 0;
|
|
13
13
|
const ranks_model_1 = require("../models/ranks.model");
|
|
14
14
|
const updateRankForUser = (user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const currentRank = yield ranks_model_1.Rank.findOne({ actionCount: { $lte: user.acceptedProjectsCounter } })
|
|
16
|
-
|
|
15
|
+
const currentRank = yield ranks_model_1.Rank.findOne({ actionCount: { $lte: user.acceptedProjectsCounter } })
|
|
16
|
+
.sort({ actionCount: -1 })
|
|
17
|
+
.exec();
|
|
18
|
+
const nextRank = yield ranks_model_1.Rank.findOne({ actionCount: { $gt: user.acceptedProjectsCounter } })
|
|
19
|
+
.sort({ actionCount: 1 })
|
|
20
|
+
.exec();
|
|
17
21
|
if (currentRank) {
|
|
18
22
|
user.rank.title = currentRank.rank;
|
|
19
23
|
user.rank.color = currentRank.color;
|
|
@@ -119,7 +119,7 @@ exports.permissions = {
|
|
|
119
119
|
PERMISSIONS.updateRoleHandler,
|
|
120
120
|
PERMISSIONS.updateRoleHandler,
|
|
121
121
|
PERMISSIONS.removeRoleHandler,
|
|
122
|
-
PERMISSIONS.getAllPermissions
|
|
122
|
+
PERMISSIONS.getAllPermissions,
|
|
123
123
|
],
|
|
124
124
|
Post: [
|
|
125
125
|
PERMISSIONS.createProjectHandler,
|
|
@@ -155,17 +155,13 @@ exports.permissions = {
|
|
|
155
155
|
rank: [
|
|
156
156
|
PERMISSIONS.createRankHandler,
|
|
157
157
|
PERMISSIONS.updateRankHandler,
|
|
158
|
-
PERMISSIONS.deleteRankHandler
|
|
158
|
+
PERMISSIONS.deleteRankHandler,
|
|
159
159
|
],
|
|
160
160
|
setting: [
|
|
161
161
|
PERMISSIONS.createSettingHandler,
|
|
162
162
|
PERMISSIONS.updateSettingHandler,
|
|
163
|
-
PERMISSIONS.deleteSettingHandler
|
|
163
|
+
PERMISSIONS.deleteSettingHandler,
|
|
164
164
|
],
|
|
165
|
-
producer: [
|
|
166
|
-
|
|
167
|
-
],
|
|
168
|
-
dashboard: [
|
|
169
|
-
PERMISSIONS.accessDashboard
|
|
170
|
-
]
|
|
165
|
+
producer: [PERMISSIONS.getProducerAnalysis],
|
|
166
|
+
dashboard: [PERMISSIONS.accessDashboard],
|
|
171
167
|
};
|
package/build/types/User.d.ts
CHANGED
|
@@ -55,16 +55,14 @@ export interface Iuser {
|
|
|
55
55
|
};
|
|
56
56
|
isVerified: boolean;
|
|
57
57
|
refreshTokens?: {
|
|
58
|
-
|
|
59
|
-
clientType: string;
|
|
58
|
+
deviceId: string;
|
|
60
59
|
token: string;
|
|
61
|
-
userAgent: string;
|
|
62
60
|
}[];
|
|
63
61
|
profileImage?: string;
|
|
64
62
|
coverImage?: string;
|
|
65
|
-
location
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
location: {
|
|
64
|
+
type: 'Point';
|
|
65
|
+
coordinates: [number, number];
|
|
68
66
|
};
|
|
69
67
|
category?: Types.ObjectId | Icategory;
|
|
70
68
|
acceptedProjectsCounter: number;
|
|
@@ -4,38 +4,38 @@ exports.NotificationDetails = void 0;
|
|
|
4
4
|
exports.NotificationDetails = {
|
|
5
5
|
newFollow: {
|
|
6
6
|
title: 'new follow',
|
|
7
|
-
message: 'new follow'
|
|
7
|
+
message: 'new follow',
|
|
8
8
|
},
|
|
9
9
|
newMessage: {
|
|
10
10
|
title: 'new message',
|
|
11
|
-
message: 'new message'
|
|
11
|
+
message: 'new message',
|
|
12
12
|
},
|
|
13
13
|
messageUpdated: {
|
|
14
14
|
title: 'updated message',
|
|
15
|
-
message: 'updated message'
|
|
15
|
+
message: 'updated message',
|
|
16
16
|
},
|
|
17
17
|
newProducerContract: {
|
|
18
18
|
title: 'new producer contract',
|
|
19
|
-
message: 'new producer contract'
|
|
19
|
+
message: 'new producer contract',
|
|
20
20
|
},
|
|
21
21
|
updatedProducerContract: {
|
|
22
22
|
title: 'update producer contract',
|
|
23
|
-
message: 'update producer contract'
|
|
23
|
+
message: 'update producer contract',
|
|
24
24
|
},
|
|
25
25
|
newProjectContract: {
|
|
26
26
|
title: 'new project contract',
|
|
27
|
-
message: 'new project contract'
|
|
27
|
+
message: 'new project contract',
|
|
28
28
|
},
|
|
29
29
|
updateProjectContract: {
|
|
30
30
|
title: 'update project contract',
|
|
31
|
-
message: 'update project contract'
|
|
31
|
+
message: 'update project contract',
|
|
32
32
|
},
|
|
33
33
|
newTeamContract: {
|
|
34
34
|
title: 'new Team contract',
|
|
35
|
-
message: 'new Team contract'
|
|
35
|
+
message: 'new Team contract',
|
|
36
36
|
},
|
|
37
37
|
updateTeamContract: {
|
|
38
38
|
title: 'update Team contract',
|
|
39
|
-
message: 'update Team contract'
|
|
39
|
+
message: 'update Team contract',
|
|
40
40
|
},
|
|
41
41
|
};
|
|
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.generateToken = void 0;
|
|
7
7
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
8
|
const generateToken = (payload) => jsonwebtoken_1.default.sign(payload, process.env.JWT_KEY, {
|
|
9
|
-
expiresIn: '1m'
|
|
9
|
+
expiresIn: '1m',
|
|
10
10
|
});
|
|
11
11
|
exports.generateToken = generateToken;
|