@social.dev/server-sdk 0.0.1-alpha.37 → 0.0.1-alpha.39
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/dist/chat/chat.service.js +1 -0
- package/dist/chat/chat.service.js.map +1 -1
- package/dist/chat/dto/responses.dto.js +1 -1
- package/dist/chat/dto/responses.dto.js.map +1 -1
- package/dist/community/community.acl.js.map +1 -1
- package/dist/migrations/1758704603161-UserFollows.d.ts +6 -0
- package/dist/migrations/1758704603161-UserFollows.js +18 -0
- package/dist/migrations/1758704603161-UserFollows.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/user/dto/user-response.dto.d.ts +2 -0
- package/dist/user/dto/user-response.dto.js +7 -1
- package/dist/user/dto/user-response.dto.js.map +1 -1
- package/dist/user/dto/user.dto.d.ts +8 -0
- package/dist/user/dto/user.dto.js +21 -0
- package/dist/user/dto/user.dto.js.map +1 -0
- package/dist/user/entities/user.entity.js.map +1 -1
- package/dist/user/follow/dto/follow-response.dto.d.ts +4 -0
- package/dist/user/follow/dto/follow-response.dto.js +38 -0
- package/dist/user/follow/dto/follow-response.dto.js.map +1 -0
- package/dist/user/follow/dto/follow.dto.d.ts +4 -0
- package/dist/user/follow/dto/follow.dto.js +26 -0
- package/dist/user/follow/dto/follow.dto.js.map +1 -0
- package/dist/user/follow/entities/follow.entity.d.ts +10 -0
- package/dist/user/follow/entities/follow.entity.js +60 -0
- package/dist/user/follow/entities/follow.entity.js.map +1 -0
- package/dist/user/follow/follow.controller.d.ts +9 -0
- package/dist/user/follow/follow.controller.js +56 -0
- package/dist/user/follow/follow.controller.js.map +1 -0
- package/dist/user/follow/follow.module.d.ts +2 -0
- package/dist/user/follow/follow.module.js +26 -0
- package/dist/user/follow/follow.module.js.map +1 -0
- package/dist/user/follow/follow.service.d.ts +11 -0
- package/dist/user/follow/follow.service.js +56 -0
- package/dist/user/follow/follow.service.js.map +1 -0
- package/dist/user/user.module.js +4 -1
- package/dist/user/user.module.js.map +1 -1
- package/dist/user/user.service.d.ts +8 -3
- package/dist/user/user.service.js +36 -7
- package/dist/user/user.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AVATAR_SIZES } from '~/user/avatar/avatar.service';
|
|
2
|
+
import { UserRelationsDto } from './user.dto';
|
|
2
3
|
export declare class UserResponseDto {
|
|
3
4
|
id: number;
|
|
4
5
|
username: string;
|
|
@@ -6,4 +7,5 @@ export declare class UserResponseDto {
|
|
|
6
7
|
avatar: Record<(typeof AVATAR_SIZES)[number], {
|
|
7
8
|
url: string;
|
|
8
9
|
}>;
|
|
10
|
+
relations: UserRelationsDto;
|
|
9
11
|
}
|
|
@@ -15,13 +15,15 @@ const swagger_1 = require("@nestjs/swagger");
|
|
|
15
15
|
const class_transformer_1 = require("class-transformer");
|
|
16
16
|
const context_1 = require("../../core/context/context");
|
|
17
17
|
const avatar_service_1 = require("../avatar/avatar.service");
|
|
18
|
+
const user_dto_1 = require("./user.dto");
|
|
18
19
|
class UserResponseDto {
|
|
19
20
|
id;
|
|
20
21
|
username;
|
|
21
22
|
name;
|
|
22
23
|
avatar;
|
|
24
|
+
relations;
|
|
23
25
|
static _OPENAPI_METADATA_FACTORY() {
|
|
24
|
-
return { id: { required: true, type: () => Number }, username: { required: true, type: () => String }, name: { required: true, type: () => String }, avatar: { required: true, type: () => Object } };
|
|
26
|
+
return { id: { required: true, type: () => Number }, username: { required: true, type: () => String }, name: { required: true, type: () => String }, avatar: { required: true, type: () => Object }, relations: { required: true, type: () => require("./user.dto").UserRelationsDto } };
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
exports.UserResponseDto = UserResponseDto;
|
|
@@ -67,4 +69,8 @@ __decorate([
|
|
|
67
69
|
}),
|
|
68
70
|
__metadata("design:type", Object)
|
|
69
71
|
], UserResponseDto.prototype, "avatar", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, class_transformer_1.Expose)(),
|
|
74
|
+
__metadata("design:type", user_dto_1.UserRelationsDto)
|
|
75
|
+
], UserResponseDto.prototype, "relations", void 0);
|
|
70
76
|
//# sourceMappingURL=user-response.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-response.dto.js","sourceRoot":"","sources":["../../../src/user/dto/user-response.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,yDAAsD;AACtD,wDAAiD;AACjD,6DAA4D;
|
|
1
|
+
{"version":3,"file":"user-response.dto.js","sourceRoot":"","sources":["../../../src/user/dto/user-response.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,yDAAsD;AACtD,wDAAiD;AACjD,6DAA4D;AAC5D,yCAA8C;AAE9C,MAAa,eAAe;IAG1B,EAAE,CAAS;IAIX,QAAQ,CAAS;IAIjB,IAAI,CAAS;IA2Bb,MAAM,CAAyD;IAG/D,SAAS,CAAmB;;;;CAC7B;AA1CD,0CA0CC;AAvCC;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mCAAmC,EAAE,CAAC;IACjE,IAAA,0BAAM,GAAE;;2CACE;AAIX;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC5D,IAAA,0BAAM,GAAE;;iDACQ;AAIjB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;IACzE,IAAA,0BAAM,GAAE;;6CACI;AA2Bb;IAzBC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,wCAAwC;QACrD,IAAI,EAAE,QAAQ;QACd,oBAAoB,EAAE;YACpB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,GAAG,EAAE;oBACH,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,KAAK;oBACb,WAAW,EAAE,qDAAqD;iBACnE;aACF;SACF;KACF,CAAC;IACD,IAAA,0BAAM,GAAE;IACR,IAAA,6BAAS,EAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;QACrB,MAAM,OAAO,GACX,iBAAO,CAAC,UAAU,EAAE,CAAC,UAAU,EAAE,GAAG,qBAAqB,GAAG,GAAG,CAAC,EAAE,CAAC;QACrE,OAAO,6BAAY,CAAC,MAAM,CAAkC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACxE,GAAG,CAAC,IAAI,CAAC,GAAG;gBACV,GAAG,EAAE,GAAG,OAAO,IAAI,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO;aAC1D,CAAC;YACF,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC;;+CAC6D;AAG/D;IADC,IAAA,0BAAM,GAAE;8BACE,2BAAgB;kDAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserRelationsDto = exports.UserDto = void 0;
|
|
4
|
+
const openapi = require("@nestjs/swagger");
|
|
5
|
+
const user_entity_1 = require("../entities/user.entity");
|
|
6
|
+
class UserDto extends user_entity_1.User {
|
|
7
|
+
relations;
|
|
8
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
9
|
+
return { relations: { required: true, type: () => require("./user.dto").UserRelationsDto } };
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.UserDto = UserDto;
|
|
13
|
+
class UserRelationsDto {
|
|
14
|
+
isFollowing;
|
|
15
|
+
isFollowed;
|
|
16
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
17
|
+
return { isFollowing: { required: false, type: () => Boolean }, isFollowed: { required: false, type: () => Boolean } };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.UserRelationsDto = UserRelationsDto;
|
|
21
|
+
//# sourceMappingURL=user.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.dto.js","sourceRoot":"","sources":["../../../src/user/dto/user.dto.ts"],"names":[],"mappings":";;;;AAAA,yDAA+C;AAE/C,MAAa,OAAQ,SAAQ,kBAAI;IAI/B,SAAS,CAAmB;;;;CAC7B;AALD,0BAKC;AAED,MAAa,gBAAgB;IAC3B,WAAW,CAAW;IACtB,UAAU,CAAW;;;;CACtB;AAHD,4CAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/user/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0EAA4D;AAE5D,
|
|
1
|
+
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/user/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0EAA4D;AAE5D,qCAYiB;AACjB,yDAA4C;AAC5C,8FAA+E;AAC/E,+FAAoF;AAK7E,IAAM,IAAI,GAAV,MAAM,IAAI;IAKf,OAAO,CAAU;IAMjB,EAAE,CAAS;IAGX,IAAI,CAAS;IAIb,QAAQ,CAAS;IAIjB,KAAK,CAAS;IAId,QAAQ,CAAS;IAMjB,WAAW,CAAoB;IAQ/B,KAAK,CAA2B;IAMhC,SAAS,CAAO;IAMhB,SAAS,CAAO;;;;CACjB,CAAA;AArDY,oBAAI;AAKf;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAO,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;8BACzC,wBAAO;qCAAC;AAMjB;IADC,IAAA,gCAAsB,GAAE;;gCACd;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;kCAC3B;AAIb;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACvC,IAAA,gBAAM,EAAC,iBAAiB,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;;sCAClC;AAIjB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACvC,IAAA,2BAAO,GAAE;;mCACI;AAId;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,2BAAO,GAAE;;sCACO;AAMjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,yCAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;;yCAC9C;AAQ/B;IAHC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,mDAAsB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE;QAC5D,QAAQ,EAAE,SAAS;KACpB,CAAC;;mCAC8B;AAMhC;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;uCAAC;AAMhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;uCAAC;eApDL,IAAI;IADhB,IAAA,gBAAM,GAAE;GACI,IAAI,CAqDhB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FollowResponseDto = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const class_transformer_1 = require("class-transformer");
|
|
16
|
+
class FollowResponseDto {
|
|
17
|
+
following;
|
|
18
|
+
approved;
|
|
19
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
20
|
+
return { following: { required: true, type: () => Boolean }, approved: { required: true, type: () => Boolean } };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.FollowResponseDto = FollowResponseDto;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)({
|
|
26
|
+
description: 'True/False of the following state',
|
|
27
|
+
}),
|
|
28
|
+
(0, class_transformer_1.Expose)(),
|
|
29
|
+
__metadata("design:type", Boolean)
|
|
30
|
+
], FollowResponseDto.prototype, "following", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, swagger_1.ApiProperty)({
|
|
33
|
+
description: 'Status of the follow. If false, the target user needs to approve.',
|
|
34
|
+
}),
|
|
35
|
+
(0, class_transformer_1.Expose)(),
|
|
36
|
+
__metadata("design:type", Boolean)
|
|
37
|
+
], FollowResponseDto.prototype, "approved", void 0);
|
|
38
|
+
//# sourceMappingURL=follow-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow-response.dto.js","sourceRoot":"","sources":["../../../../src/user/follow/dto/follow-response.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,yDAA2C;AAE3C,MAAa,iBAAiB;IAK5B,SAAS,CAAU;IAOnB,QAAQ,CAAU;;;;CACnB;AAbD,8CAaC;AARC;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,mCAAmC;KACjD,CAAC;IACD,IAAA,0BAAM,GAAE;;oDACU;AAOnB;IALC,IAAA,qBAAW,EAAC;QACX,WAAW,EACT,mEAAmE;KACtE,CAAC;IACD,IAAA,0BAAM,GAAE;;mDACS"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FollowDto = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
class FollowDto {
|
|
16
|
+
user;
|
|
17
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
18
|
+
return { user: { required: true, type: () => Number } };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.FollowDto = FollowDto;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, swagger_1.ApiProperty)({ description: 'Target user to follow or unfollow' }),
|
|
24
|
+
__metadata("design:type", Object)
|
|
25
|
+
], FollowDto.prototype, "user", void 0);
|
|
26
|
+
//# sourceMappingURL=follow.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.dto.js","sourceRoot":"","sources":["../../../../src/user/follow/dto/follow.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAG9C,MAAa,SAAS;IAEpB,IAAI,CAAa;;;;CAClB;AAHD,8BAGC;AADC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mCAAmC,EAAE,CAAC;;uCACjD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Follow = void 0;
|
|
13
|
+
const openapi = require("@nestjs/swagger");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const user_entity_1 = require("../../entities/user.entity");
|
|
16
|
+
let Follow = class Follow {
|
|
17
|
+
userId;
|
|
18
|
+
user;
|
|
19
|
+
targetUserId;
|
|
20
|
+
targetUser;
|
|
21
|
+
approved;
|
|
22
|
+
createdAt;
|
|
23
|
+
updatedAt;
|
|
24
|
+
static _OPENAPI_METADATA_FACTORY() {
|
|
25
|
+
return { userId: { required: true, type: () => Number }, user: { required: true, type: () => require("../../entities/user.entity").User }, targetUserId: { required: true, type: () => Number }, targetUser: { required: true, type: () => require("../../entities/user.entity").User }, approved: { required: true, type: () => Boolean }, createdAt: { required: true, type: () => Date }, updatedAt: { required: true, type: () => Date } };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.Follow = Follow;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.PrimaryColumn)(),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], Follow.prototype, "userId", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
|
|
35
|
+
__metadata("design:type", user_entity_1.User)
|
|
36
|
+
], Follow.prototype, "user", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.PrimaryColumn)(),
|
|
39
|
+
__metadata("design:type", Object)
|
|
40
|
+
], Follow.prototype, "targetUserId", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
|
|
43
|
+
__metadata("design:type", user_entity_1.User)
|
|
44
|
+
], Follow.prototype, "targetUser", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ default: true }),
|
|
47
|
+
__metadata("design:type", Boolean)
|
|
48
|
+
], Follow.prototype, "approved", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
51
|
+
__metadata("design:type", Date)
|
|
52
|
+
], Follow.prototype, "createdAt", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
55
|
+
__metadata("design:type", Date)
|
|
56
|
+
], Follow.prototype, "updatedAt", void 0);
|
|
57
|
+
exports.Follow = Follow = __decorate([
|
|
58
|
+
(0, typeorm_1.Entity)()
|
|
59
|
+
], Follow);
|
|
60
|
+
//# sourceMappingURL=follow.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.entity.js","sourceRoot":"","sources":["../../../../src/user/follow/entities/follow.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAOiB;AACjB,4DAAmD;AAG5C,IAAM,MAAM,GAAZ,MAAM,MAAM;IAMR,MAAM,CAAa;IAM5B,IAAI,CAAO;IAOF,YAAY,CAAa;IAMlC,UAAU,CAAO;IAQjB,QAAQ,CAAU;IAMlB,SAAS,CAAO;IAMhB,SAAS,CAAO;;;;CACjB,CAAA;AA9CY,wBAAM;AAMR;IADR,IAAA,uBAAa,GAAE;;sCACY;AAM5B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;8BAChB,kBAAI;oCAAC;AAOF;IADR,IAAA,uBAAa,GAAE;;4CACkB;AAMlC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;8BACV,kBAAI;0CAAC;AAQjB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;wCACR;AAMlB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAC;AAMhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAC;iBA7CL,MAAM;IADlB,IAAA,gBAAM,GAAE;GACI,MAAM,CA8ClB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FollowDto } from './dto/follow.dto';
|
|
2
|
+
import { FollowResponseDto } from './dto/follow-response.dto';
|
|
3
|
+
import { FollowService } from './follow.service';
|
|
4
|
+
export declare class FollowController {
|
|
5
|
+
private service;
|
|
6
|
+
constructor(service: FollowService);
|
|
7
|
+
follow(dto: FollowDto): Promise<FollowResponseDto>;
|
|
8
|
+
unfollow(dto: FollowDto): Promise<FollowResponseDto>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FollowController = void 0;
|
|
16
|
+
const openapi = require("@nestjs/swagger");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const follow_dto_1 = require("./dto/follow.dto");
|
|
19
|
+
const auth_guard_1 = require("../../auth/auth.guard");
|
|
20
|
+
const follow_service_1 = require("./follow.service");
|
|
21
|
+
let FollowController = class FollowController {
|
|
22
|
+
service;
|
|
23
|
+
constructor(service) {
|
|
24
|
+
this.service = service;
|
|
25
|
+
}
|
|
26
|
+
follow(dto) {
|
|
27
|
+
return this.service.follow(dto.user);
|
|
28
|
+
}
|
|
29
|
+
unfollow(dto) {
|
|
30
|
+
return this.service.unfollow(dto.user);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.FollowController = FollowController;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, common_1.Post)('user.follow'),
|
|
36
|
+
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
|
|
37
|
+
openapi.ApiResponse({ status: 201, type: require("./dto/follow-response.dto").FollowResponseDto }),
|
|
38
|
+
__param(0, (0, common_1.Body)()),
|
|
39
|
+
__metadata("design:type", Function),
|
|
40
|
+
__metadata("design:paramtypes", [follow_dto_1.FollowDto]),
|
|
41
|
+
__metadata("design:returntype", Promise)
|
|
42
|
+
], FollowController.prototype, "follow", null);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, common_1.Post)('user.unfollow'),
|
|
45
|
+
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
|
|
46
|
+
openapi.ApiResponse({ status: 201, type: require("./dto/follow-response.dto").FollowResponseDto }),
|
|
47
|
+
__param(0, (0, common_1.Body)()),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", [follow_dto_1.FollowDto]),
|
|
50
|
+
__metadata("design:returntype", Promise)
|
|
51
|
+
], FollowController.prototype, "unfollow", null);
|
|
52
|
+
exports.FollowController = FollowController = __decorate([
|
|
53
|
+
(0, common_1.Controller)(),
|
|
54
|
+
__metadata("design:paramtypes", [follow_service_1.FollowService])
|
|
55
|
+
], FollowController);
|
|
56
|
+
//# sourceMappingURL=follow.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.controller.js","sourceRoot":"","sources":["../../../src/user/follow/follow.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAmE;AACnE,iDAA6C;AAE7C,sDAA8C;AAC9C,qDAAiD;AAG1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACP;IAApB,YAAoB,OAAsB;QAAtB,YAAO,GAAP,OAAO,CAAe;IAAG,CAAC;IAG9C,MAAM,CAAS,GAAc;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAID,QAAQ,CAAS,GAAc;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AAbY,4CAAgB;AAI3B;IAFC,IAAA,aAAI,EAAC,aAAa,CAAC;IACnB,IAAA,kBAAS,EAAC,sBAAS,CAAC;;IACb,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,sBAAS;;8CAE5B;AAID;IAFC,IAAA,aAAI,EAAC,eAAe,CAAC;IACrB,IAAA,kBAAS,EAAC,sBAAS,CAAC;;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,sBAAS;;gDAE9B;2BAZU,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAEkB,8BAAa;GAD/B,gBAAgB,CAa5B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FollowModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const follow_entity_1 = require("./entities/follow.entity");
|
|
13
|
+
const follow_service_1 = require("./follow.service");
|
|
14
|
+
const follow_controller_1 = require("./follow.controller");
|
|
15
|
+
let FollowModule = class FollowModule {
|
|
16
|
+
};
|
|
17
|
+
exports.FollowModule = FollowModule;
|
|
18
|
+
exports.FollowModule = FollowModule = __decorate([
|
|
19
|
+
(0, common_1.Module)({
|
|
20
|
+
imports: [typeorm_1.TypeOrmModule.forFeature([follow_entity_1.Follow])],
|
|
21
|
+
controllers: [follow_controller_1.FollowController],
|
|
22
|
+
providers: [follow_service_1.FollowService],
|
|
23
|
+
exports: [follow_service_1.FollowService],
|
|
24
|
+
})
|
|
25
|
+
], FollowModule);
|
|
26
|
+
//# sourceMappingURL=follow.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.module.js","sourceRoot":"","sources":["../../../src/user/follow/follow.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,4DAAkD;AAClD,qDAAiD;AACjD,2DAAuD;AAQhD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IANxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,sBAAM,CAAC,CAAC,CAAC;QAC7C,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { User } from '../entities/user.entity';
|
|
2
|
+
import { Follow } from './entities/follow.entity';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
import { FollowResponseDto } from './dto/follow-response.dto';
|
|
5
|
+
export declare class FollowService {
|
|
6
|
+
private repository;
|
|
7
|
+
constructor(repository: Repository<Follow>);
|
|
8
|
+
isFollowing(user: User, targetUser: User): Promise<boolean>;
|
|
9
|
+
follow(targetUserId: User['id']): Promise<FollowResponseDto>;
|
|
10
|
+
unfollow(targetUserId: User['id']): Promise<FollowResponseDto>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FollowService = void 0;
|
|
16
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
17
|
+
const follow_entity_1 = require("./entities/follow.entity");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const context_1 = require("../../core/context/context");
|
|
20
|
+
let FollowService = class FollowService {
|
|
21
|
+
repository;
|
|
22
|
+
constructor(repository) {
|
|
23
|
+
this.repository = repository;
|
|
24
|
+
}
|
|
25
|
+
async isFollowing(user, targetUser) {
|
|
26
|
+
return !!(await this.repository.findOne({
|
|
27
|
+
where: {
|
|
28
|
+
userId: user.id,
|
|
29
|
+
targetUserId: targetUser.id,
|
|
30
|
+
approved: true,
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
async follow(targetUserId) {
|
|
35
|
+
const user = context_1.Context.getUser();
|
|
36
|
+
const res = await this.repository.insert({
|
|
37
|
+
targetUser: { id: targetUserId },
|
|
38
|
+
user: { id: user.id },
|
|
39
|
+
});
|
|
40
|
+
return { following: !!res.raw, approved: true };
|
|
41
|
+
}
|
|
42
|
+
async unfollow(targetUserId) {
|
|
43
|
+
const user = context_1.Context.getUser();
|
|
44
|
+
const res = await this.repository.delete({
|
|
45
|
+
targetUser: { id: targetUserId },
|
|
46
|
+
user: { id: user.id },
|
|
47
|
+
});
|
|
48
|
+
return { following: res.affected === 1 ? false : true, approved: true };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.FollowService = FollowService;
|
|
52
|
+
exports.FollowService = FollowService = __decorate([
|
|
53
|
+
__param(0, (0, typeorm_1.InjectRepository)(follow_entity_1.Follow)),
|
|
54
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
55
|
+
], FollowService);
|
|
56
|
+
//# sourceMappingURL=follow.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.service.js","sourceRoot":"","sources":["../../../src/user/follow/follow.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAmD;AAEnD,4DAAkD;AAClD,qCAAqC;AAErC,wDAAiD;AAEjD,IAAa,aAAa,GAA1B,MAAa,aAAa;IAEY;IADpC,YACoC,UAA8B;QAA9B,eAAU,GAAV,UAAU,CAAoB;IAC/D,CAAC;IAKJ,KAAK,CAAC,WAAW,CAAC,IAAU,EAAE,UAAgB;QAC5C,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACtC,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,YAAY,EAAE,UAAU,CAAC,EAAE;gBAC3B,QAAQ,EAAE,IAAI;aACf;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,YAAwB;QACnC,MAAM,IAAI,GAAG,iBAAO,CAAC,OAAO,EAAU,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACvC,UAAU,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE;YAChC,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;SACtB,CAAC,CAAC;QAEH,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAwB;QACrC,MAAM,IAAI,GAAG,iBAAO,CAAC,OAAO,EAAU,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACvC,UAAU,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE;YAChC,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;SACtB,CAAC,CAAC;QACH,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1E,CAAC;CACF,CAAA;AApCY,sCAAa;wBAAb,aAAa;IAErB,WAAA,IAAA,0BAAgB,EAAC,sBAAM,CAAC,CAAA;qCAAqB,oBAAU;GAF/C,aAAa,CAoCzB"}
|
package/dist/user/user.module.js
CHANGED
|
@@ -22,17 +22,20 @@ const hook_module_1 = require("../core/hook/hook.module");
|
|
|
22
22
|
const avatar_controller_1 = require("./avatar/avatar.controller");
|
|
23
23
|
const avatar_service_1 = require("./avatar/avatar.service");
|
|
24
24
|
const file_storage_module_1 = require("../file-storage/file-storage.module");
|
|
25
|
+
const follow_module_1 = require("./follow/follow.module");
|
|
26
|
+
const follow_entity_1 = require("./follow/entities/follow.entity");
|
|
25
27
|
let UserModule = class UserModule {
|
|
26
28
|
};
|
|
27
29
|
exports.UserModule = UserModule;
|
|
28
30
|
exports.UserModule = UserModule = __decorate([
|
|
29
31
|
(0, common_1.Module)({
|
|
30
32
|
imports: [
|
|
31
|
-
typeorm_1.TypeOrmModule.forFeature([user_entity_1.User]),
|
|
33
|
+
typeorm_1.TypeOrmModule.forFeature([user_entity_1.User, follow_entity_1.Follow]),
|
|
32
34
|
(0, common_1.forwardRef)(() => post_module_1.PostModule),
|
|
33
35
|
acl_module_1.AclModule.forChild(user_acl_1.default),
|
|
34
36
|
hook_module_1.HookModule,
|
|
35
37
|
file_storage_module_1.FileStorageModule,
|
|
38
|
+
follow_module_1.FollowModule,
|
|
36
39
|
],
|
|
37
40
|
controllers: [user_controller_1.UserController, avatar_controller_1.UserAvatarController],
|
|
38
41
|
providers: [user_service_1.UserService, avatar_service_1.UserAvatarService],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.module.js","sourceRoot":"","sources":["../../src/user/user.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoD;AACpD,iDAA6C;AAC7C,uDAAmD;AACnD,wDAA8C;AAC9C,6CAAgD;AAChD,qDAAgD;AAChD,uDAAkD;AAClD,0DAAsC;AACtC,0DAAqD;AACrD,kEAAkE;AAClE,4DAA4D;AAC5D,6EAAuE;
|
|
1
|
+
{"version":3,"file":"user.module.js","sourceRoot":"","sources":["../../src/user/user.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoD;AACpD,iDAA6C;AAC7C,uDAAmD;AACnD,wDAA8C;AAC9C,6CAAgD;AAChD,qDAAgD;AAChD,uDAAkD;AAClD,0DAAsC;AACtC,0DAAqD;AACrD,kEAAkE;AAClE,4DAA4D;AAC5D,6EAAuE;AACvE,0DAAsD;AACtD,mEAAyD;AAelD,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAbtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,sBAAM,CAAC,CAAC;YACxC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,sBAAS,CAAC,QAAQ,CAAC,kBAAY,CAAC;YAChC,wBAAU;YACV,uCAAiB;YACjB,4BAAY;SACb;QACD,WAAW,EAAE,CAAC,gCAAc,EAAE,wCAAoB,CAAC;QACnD,SAAS,EAAE,CAAC,0BAAW,EAAE,kCAAiB,CAAC;QAC3C,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAG"}
|
|
@@ -3,11 +3,14 @@ import { User } from './entities/user.entity';
|
|
|
3
3
|
import { QueryRunner, Repository } from 'typeorm';
|
|
4
4
|
import { DataSource } from 'typeorm';
|
|
5
5
|
import { HookService } from '~/core/hook/hook.service';
|
|
6
|
+
import { UserDto } from './dto/user.dto';
|
|
7
|
+
import { FollowService } from './follow/follow.service';
|
|
6
8
|
export declare class UserService {
|
|
7
9
|
private readonly repository;
|
|
8
10
|
private readonly dataSource;
|
|
9
11
|
private readonly hookService;
|
|
10
|
-
|
|
12
|
+
private readonly followService;
|
|
13
|
+
constructor(repository: Repository<User>, dataSource: DataSource, hookService: HookService, followService: FollowService);
|
|
11
14
|
create({ username, name, email, password, verified, }: {
|
|
12
15
|
username: string;
|
|
13
16
|
name: string;
|
|
@@ -17,8 +20,10 @@ export declare class UserService {
|
|
|
17
20
|
}, queryRunner?: QueryRunner): Promise<User>;
|
|
18
21
|
verifyUsername(username: string, queryRunner?: QueryRunner): Promise<boolean>;
|
|
19
22
|
findAll(): Promise<User[]>;
|
|
20
|
-
findOne(id: number): Promise<
|
|
21
|
-
findOneByUsername(username: string): Promise<
|
|
23
|
+
findOne(id: number): Promise<UserDto | null>;
|
|
24
|
+
findOneByUsername(username: string): Promise<UserDto | null>;
|
|
25
|
+
buildUserDto(user: User): Promise<UserDto>;
|
|
22
26
|
updateProfile(dto: UpdateProfileDto, user: User): Promise<import("typeorm").UpdateResult>;
|
|
23
27
|
remove(id: number): string;
|
|
28
|
+
private buildUserQuery;
|
|
24
29
|
}
|
|
@@ -22,14 +22,17 @@ const user_exceptions_1 = require("./user.exceptions");
|
|
|
22
22
|
const typeorm_3 = require("typeorm");
|
|
23
23
|
const hook_service_1 = require("../core/hook/hook.service");
|
|
24
24
|
const constants_1 = require("./constants");
|
|
25
|
+
const follow_service_1 = require("./follow/follow.service");
|
|
25
26
|
let UserService = class UserService {
|
|
26
27
|
repository;
|
|
27
28
|
dataSource;
|
|
28
29
|
hookService;
|
|
29
|
-
|
|
30
|
+
followService;
|
|
31
|
+
constructor(repository, dataSource, hookService, followService) {
|
|
30
32
|
this.repository = repository;
|
|
31
33
|
this.dataSource = dataSource;
|
|
32
34
|
this.hookService = hookService;
|
|
35
|
+
this.followService = followService;
|
|
33
36
|
}
|
|
34
37
|
async create({ username, name, email, password, verified = false, }, queryRunner) {
|
|
35
38
|
if (!queryRunner) {
|
|
@@ -72,14 +75,36 @@ let UserService = class UserService {
|
|
|
72
75
|
findAll() {
|
|
73
76
|
return this.repository.find();
|
|
74
77
|
}
|
|
75
|
-
findOne(id) {
|
|
76
|
-
|
|
78
|
+
async findOne(id) {
|
|
79
|
+
const user = await this.repository.findOne({
|
|
77
80
|
where: { id },
|
|
78
|
-
relations: ['communities'
|
|
81
|
+
relations: ['communities'],
|
|
79
82
|
});
|
|
83
|
+
if (!user) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return await this.buildUserDto(user);
|
|
87
|
+
}
|
|
88
|
+
async findOneByUsername(username) {
|
|
89
|
+
const user = await this.buildUserQuery()
|
|
90
|
+
.where('username = :username', { username })
|
|
91
|
+
.getOne();
|
|
92
|
+
if (!user) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return await this.buildUserDto(user);
|
|
80
96
|
}
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
async buildUserDto(user) {
|
|
98
|
+
const currentUser = context_1.Context.getUser();
|
|
99
|
+
const isFollowing = !!currentUser &&
|
|
100
|
+
currentUser.id !== user.id &&
|
|
101
|
+
(await this.followService.isFollowing(context_1.Context.getUser(), user));
|
|
102
|
+
return {
|
|
103
|
+
...user,
|
|
104
|
+
relations: {
|
|
105
|
+
isFollowing,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
83
108
|
}
|
|
84
109
|
updateProfile(dto, user) {
|
|
85
110
|
return this.repository.update({ id: user.id }, dto);
|
|
@@ -87,6 +112,9 @@ let UserService = class UserService {
|
|
|
87
112
|
remove(id) {
|
|
88
113
|
return `This action removes a #${id} user`;
|
|
89
114
|
}
|
|
115
|
+
buildUserQuery() {
|
|
116
|
+
return this.repository.createQueryBuilder('user');
|
|
117
|
+
}
|
|
90
118
|
};
|
|
91
119
|
exports.UserService = UserService;
|
|
92
120
|
exports.UserService = UserService = __decorate([
|
|
@@ -94,6 +122,7 @@ exports.UserService = UserService = __decorate([
|
|
|
94
122
|
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
|
|
95
123
|
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
96
124
|
typeorm_3.DataSource,
|
|
97
|
-
hook_service_1.HookService
|
|
125
|
+
hook_service_1.HookService,
|
|
126
|
+
follow_service_1.FollowService])
|
|
98
127
|
], UserService);
|
|
99
128
|
//# sourceMappingURL=user.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,6CAAmD;AACnD,wDAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,6CAAmD;AACnD,wDAA8C;AAC9C,qCAAsE;AACtE,qDAAiD;AACjD,uDAG2B;AAC3B,qCAAqC;AACrC,4DAAuD;AACvD,2CAA2C;AAG3C,4DAAwD;AAGjD,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEqB;IACxB;IACA;IACA;IAJnB,YAC2C,UAA4B,EACpD,UAAsB,EACtB,WAAwB,EACxB,aAA4B;QAHJ,eAAU,GAAV,UAAU,CAAkB;QACpD,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,G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