Configure remote database connection and update documentation
This commit is contained in:
60
DATABASE_SETUP.md
Normal file
60
DATABASE_SETUP.md
Normal file
@ -0,0 +1,60 @@
|
||||
# Настройка базы данных для Prism Messenger
|
||||
|
||||
## Использование удаленной базы данных
|
||||
|
||||
Проект настроен для работы с удаленной PostgreSQL базой данных.
|
||||
|
||||
### Конфигурация
|
||||
|
||||
1. Скопируйте `.env.example` в `.env`:
|
||||
```bash
|
||||
cd backend
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. Обновите параметры подключения в `.env`:
|
||||
```env
|
||||
DATABASE_HOST=85.234.110.60
|
||||
DATABASE_PORT=5432
|
||||
DATABASE_USERNAME=prism
|
||||
DATABASE_PASSWORD=oaZ3-4Y6yf
|
||||
DATABASE_NAME=prism
|
||||
```
|
||||
|
||||
### Проверка подключения
|
||||
|
||||
Если возникают проблемы с подключением:
|
||||
|
||||
1. **Проверьте правильность credentials**
|
||||
- Убедитесь, что пароль скопирован правильно
|
||||
- Проверьте, что в пароле нет лишних пробелов
|
||||
|
||||
2. **Проверьте доступ с вашего IP**
|
||||
- Возможно, нужно добавить ваш IP в whitelist базы данных
|
||||
- Свяжитесь с администратором БД
|
||||
|
||||
3. **Тестирование подключения через psql**:
|
||||
```bash
|
||||
psql 'postgresql://prism:oaZ3-4Y6yf@85.234.110.60:5432/prism'
|
||||
```
|
||||
|
||||
### Альтернативная локальная разработка
|
||||
|
||||
Если нет доступа к удаленной БД, можно использовать локальную:
|
||||
|
||||
1. Раскомментируйте сервис postgres в `docker-compose.yml`
|
||||
2. Запустите: `docker-compose up -d`
|
||||
3. Обновите `.env` для локальной БД:
|
||||
```env
|
||||
DATABASE_HOST=localhost
|
||||
DATABASE_PORT=5432
|
||||
DATABASE_USERNAME=postgres
|
||||
DATABASE_PASSWORD=postgres
|
||||
DATABASE_NAME=prism_messenger
|
||||
```
|
||||
|
||||
## Миграции
|
||||
|
||||
При первом запуске NestJS автоматически создаст необходимые таблицы благодаря `synchronize: true` в конфигурации TypeORM.
|
||||
|
||||
**Важно**: В продакшене обязательно установите `synchronize: false` и используйте миграции!
|
@ -24,8 +24,15 @@
|
||||
- Docker и Docker Compose
|
||||
- Expo Go на мобильном устройстве
|
||||
|
||||
### 1. Запуск базы данных
|
||||
### 1. Настройка базы данных
|
||||
|
||||
#### Вариант A: Удаленная база данных (рекомендуется)
|
||||
Проект настроен для работы с удаленной PostgreSQL.
|
||||
См. [DATABASE_SETUP.md](DATABASE_SETUP.md) для деталей конфигурации.
|
||||
|
||||
#### Вариант B: Локальная база данных
|
||||
```bash
|
||||
# Раскомментируйте сервис postgres в docker-compose.yml
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
|
2
backend/dist/app.module.d.ts
vendored
Normal file
2
backend/dist/app.module.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare class AppModule {
|
||||
}
|
58
backend/dist/app.module.js
vendored
Normal file
58
backend/dist/app.module.js
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const apollo_1 = require("@nestjs/apollo");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const path_1 = require("path");
|
||||
const auth_module_1 = require("./modules/auth/auth.module");
|
||||
const users_module_1 = require("./modules/users/users.module");
|
||||
const conversations_module_1 = require("./modules/conversations/conversations.module");
|
||||
const messages_module_1 = require("./modules/messages/messages.module");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
exports.AppModule = AppModule;
|
||||
exports.AppModule = AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
config_1.ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
}),
|
||||
graphql_1.GraphQLModule.forRoot({
|
||||
driver: apollo_1.ApolloDriver,
|
||||
autoSchemaFile: (0, path_1.join)(process.cwd(), 'src/schema.gql'),
|
||||
sortSchema: true,
|
||||
subscriptions: {
|
||||
'graphql-ws': true,
|
||||
},
|
||||
context: ({ req }) => ({ req }),
|
||||
}),
|
||||
typeorm_1.TypeOrmModule.forRoot({
|
||||
type: 'postgres',
|
||||
host: process.env.DATABASE_HOST || 'localhost',
|
||||
port: parseInt(process.env.DATABASE_PORT, 10) || 5432,
|
||||
username: process.env.DATABASE_USERNAME || 'postgres',
|
||||
password: process.env.DATABASE_PASSWORD || 'postgres',
|
||||
database: process.env.DATABASE_NAME || 'prism_messenger',
|
||||
entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
||||
synchronize: true,
|
||||
logging: true,
|
||||
}),
|
||||
auth_module_1.AuthModule,
|
||||
users_module_1.UsersModule,
|
||||
conversations_module_1.ConversationsModule,
|
||||
messages_module_1.MessagesModule,
|
||||
],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
})
|
||||
], AppModule);
|
||||
//# sourceMappingURL=app.module.js.map
|
1
backend/dist/app.module.js.map
vendored
Normal file
1
backend/dist/app.module.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,2CAAkE;AAClE,6CAAgD;AAChD,2CAA8C;AAC9C,+BAA4B;AAC5B,4DAAwD;AACxD,+DAA2D;AAC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ist/config/typeorm.config.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
export declare const getTypeOrmConfig: (configService: ConfigService) => TypeOrmModuleOptions;
|
17
backend/dist/config/typeorm.config.js
vendored
Normal file
17
backend/dist/config/typeorm.config.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getTypeOrmConfig = void 0;
|
||||
const getTypeOrmConfig = (configService) => ({
|
||||
type: 'postgres',
|
||||
host: configService.get('DATABASE_HOST') || 'localhost',
|
||||
port: configService.get('DATABASE_PORT') || 5432,
|
||||
username: configService.get('DATABASE_USERNAME') || 'postgres',
|
||||
password: configService.get('DATABASE_PASSWORD') || 'postgres',
|
||||
database: configService.get('DATABASE_NAME') || 'prism_messenger',
|
||||
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
|
||||
migrations: [__dirname + '/../migrations/*{.ts,.js}'],
|
||||
synchronize: configService.get('NODE_ENV') !== 'production',
|
||||
logging: configService.get('NODE_ENV') !== 'production',
|
||||
});
|
||||
exports.getTypeOrmConfig = getTypeOrmConfig;
|
||||
//# sourceMappingURL=typeorm.config.js.map
|
1
backend/dist/config/typeorm.config.js.map
vendored
Normal file
1
backend/dist/config/typeorm.config.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"typeorm.config.js","sourceRoot":"","sources":["../../src/config/typeorm.config.ts"],"names":[],"mappings":";;;AAGO,MAAM,gBAAgB,GAAG,CAAC,aAA4B,EAAwB,EAAE,CAAC,CAAC;IACvF,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,WAAW;IACvD,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI;IAChD,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,UAAU;IAC9D,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,UAAU;IAC9D,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,iBAAiB;IACjE,QAAQ,EAAE,CAAC,SAAS,GAAG,0BAA0B,CAAC;IAClD,UAAU,EAAE,CAAC,SAAS,GAAG,2BAA2B,CAAC;IACrD,WAAW,EAAE,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY;IAC3D,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY;CACxD,CAAC,CAAC;AAXU,QAAA,gBAAgB,oBAW1B"}
|
1
backend/dist/main.d.ts
vendored
Normal file
1
backend/dist/main.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
10
backend/dist/main.js
vendored
Normal file
10
backend/dist/main.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core_1 = require("@nestjs/core");
|
||||
const app_module_1 = require("./app.module");
|
||||
async function bootstrap() {
|
||||
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
}
|
||||
bootstrap();
|
||||
//# sourceMappingURL=main.js.map
|
1
backend/dist/main.js.map
vendored
Normal file
1
backend/dist/main.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;AAC7C,CAAC;AACD,SAAS,EAAE,CAAC"}
|
2
backend/dist/modules/auth/auth.module.d.ts
vendored
Normal file
2
backend/dist/modules/auth/auth.module.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare class AuthModule {
|
||||
}
|
34
backend/dist/modules/auth/auth.module.js
vendored
Normal file
34
backend/dist/modules/auth/auth.module.js
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
const auth_resolver_1 = require("./auth.resolver");
|
||||
const jwt_strategy_1 = require("./strategies/jwt.strategy");
|
||||
const users_module_1 = require("../users/users.module");
|
||||
let AuthModule = class AuthModule {
|
||||
};
|
||||
exports.AuthModule = AuthModule;
|
||||
exports.AuthModule = AuthModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
users_module_1.UsersModule,
|
||||
passport_1.PassportModule,
|
||||
jwt_1.JwtModule.register({
|
||||
secret: process.env.JWT_SECRET || 'secret',
|
||||
signOptions: { expiresIn: process.env.JWT_EXPIRATION || '7d' },
|
||||
}),
|
||||
],
|
||||
providers: [auth_service_1.AuthService, auth_resolver_1.AuthResolver, jwt_strategy_1.JwtStrategy],
|
||||
exports: [auth_service_1.AuthService],
|
||||
})
|
||||
], AuthModule);
|
||||
//# sourceMappingURL=auth.module.js.map
|
1
backend/dist/modules/auth/auth.module.js.map
vendored
Normal file
1
backend/dist/modules/auth/auth.module.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qCAAwC;AACxC,+CAAkD;AAClD,iDAA6C;AAC7C,mDAA+C;AAC/C,4DAAwD;AACxD,wDAAoD;AAc7C,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAZtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,0BAAW;YACX,yBAAc;YACd,eAAS,CAAC,QAAQ,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,QAAQ;gBAC1C,WAAW,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,IAAI,EAAE;aAC/D,CAAC;SACH;QACD,SAAS,EAAE,CAAC,0BAAW,EAAE,4BAAY,EAAE,0BAAW,CAAC;QACnD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAG"}
|
14
backend/dist/modules/auth/auth.resolver.d.ts
vendored
Normal file
14
backend/dist/modules/auth/auth.resolver.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { AuthService } from './auth.service';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
export declare class AuthResolver {
|
||||
private authService;
|
||||
constructor(authService: AuthService);
|
||||
login(username: string, password: string): Promise<{
|
||||
access_token: string;
|
||||
user: User;
|
||||
}>;
|
||||
register(username: string, email: string, password: string): Promise<{
|
||||
access_token: string;
|
||||
user: User;
|
||||
}>;
|
||||
}
|
68
backend/dist/modules/auth/auth.resolver.js
vendored
Normal file
68
backend/dist/modules/auth/auth.resolver.js
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthResolver = void 0;
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
const user_entity_1 = require("../users/entities/user.entity");
|
||||
let AuthResponse = class AuthResponse {
|
||||
access_token;
|
||||
user;
|
||||
};
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(),
|
||||
__metadata("design:type", String)
|
||||
], AuthResponse.prototype, "access_token", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => user_entity_1.User),
|
||||
__metadata("design:type", user_entity_1.User)
|
||||
], AuthResponse.prototype, "user", void 0);
|
||||
AuthResponse = __decorate([
|
||||
(0, graphql_1.ObjectType)()
|
||||
], AuthResponse);
|
||||
let AuthResolver = class AuthResolver {
|
||||
authService;
|
||||
constructor(authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
async login(username, password) {
|
||||
return this.authService.login(username, password);
|
||||
}
|
||||
async register(username, email, password) {
|
||||
return this.authService.register(username, email, password);
|
||||
}
|
||||
};
|
||||
exports.AuthResolver = AuthResolver;
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => AuthResponse),
|
||||
__param(0, (0, graphql_1.Args)('username')),
|
||||
__param(1, (0, graphql_1.Args)('password')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthResolver.prototype, "login", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => AuthResponse),
|
||||
__param(0, (0, graphql_1.Args)('username')),
|
||||
__param(1, (0, graphql_1.Args)('email')),
|
||||
__param(2, (0, graphql_1.Args)('password')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, String, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthResolver.prototype, "register", null);
|
||||
exports.AuthResolver = AuthResolver = __decorate([
|
||||
(0, graphql_1.Resolver)(),
|
||||
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
||||
], AuthResolver);
|
||||
//# sourceMappingURL=auth.resolver.js.map
|
1
backend/dist/modules/auth/auth.resolver.js.map
vendored
Normal file
1
backend/dist/modules/auth/auth.resolver.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"auth.resolver.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA8E;AAC9E,iDAA6C;AAC7C,+DAAqD;AAGrD,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEhB,YAAY,CAAS;IAGrB,IAAI,CAAO;CACZ,CAAA;AAJC;IADC,IAAA,eAAK,GAAE;;kDACa;AAGrB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;8BACZ,kBAAI;0CAAC;AALP,YAAY;IADjB,IAAA,oBAAU,GAAE;GACP,YAAY,CAMjB;AAGM,IAAM,YAAY,GAAlB,MAAM,YAAY;IACH;IAApB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAG1C,AAAN,KAAK,CAAC,KAAK,CACS,QAAgB,EAChB,QAAgB;QAElC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CACM,QAAgB,EACnB,KAAa,EACV,QAAgB;QAElC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AAnBY,oCAAY;AAIjB;IADL,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC;IAE1B,WAAA,IAAA,cAAI,EAAC,UAAU,CAAC,CAAA;IAChB,WAAA,IAAA,cAAI,EAAC,UAAU,CAAC,CAAA;;;;yCAGlB;AAGK;IADL,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC;IAE1B,WAAA,IAAA,cAAI,EAAC,UAAU,CAAC,CAAA;IAChB,WAAA,IAAA,cAAI,EAAC,OAAO,CAAC,CAAA;IACb,WAAA,IAAA,cAAI,EAAC,UAAU,CAAC,CAAA;;;;4CAGlB;uBAlBU,YAAY;IADxB,IAAA,kBAAQ,GAAE;qCAEwB,0BAAW;GADjC,YAAY,CAmBxB"}
|
17
backend/dist/modules/auth/auth.service.d.ts
vendored
Normal file
17
backend/dist/modules/auth/auth.service.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { UsersService } from '../users/users.service';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
export declare class AuthService {
|
||||
private usersService;
|
||||
private jwtService;
|
||||
constructor(usersService: UsersService, jwtService: JwtService);
|
||||
validateUser(username: string, password: string): Promise<User | null>;
|
||||
login(username: string, password: string): Promise<{
|
||||
access_token: string;
|
||||
user: User;
|
||||
}>;
|
||||
register(username: string, email: string, password: string): Promise<{
|
||||
access_token: string;
|
||||
user: User;
|
||||
}>;
|
||||
}
|
90
backend/dist/modules/auth/auth.service.js
vendored
Normal file
90
backend/dist/modules/auth/auth.service.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const users_service_1 = require("../users/users.service");
|
||||
const bcrypt = __importStar(require("bcrypt"));
|
||||
let AuthService = class AuthService {
|
||||
usersService;
|
||||
jwtService;
|
||||
constructor(usersService, jwtService) {
|
||||
this.usersService = usersService;
|
||||
this.jwtService = jwtService;
|
||||
}
|
||||
async validateUser(username, password) {
|
||||
const user = await this.usersService.findByUsername(username);
|
||||
if (user && await bcrypt.compare(password, user.password)) {
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async login(username, password) {
|
||||
const user = await this.validateUser(username, password);
|
||||
if (!user) {
|
||||
throw new common_1.UnauthorizedException('Неверный логин или пароль');
|
||||
}
|
||||
const payload = { username: user.username, sub: user.id };
|
||||
return {
|
||||
access_token: this.jwtService.sign(payload),
|
||||
user,
|
||||
};
|
||||
}
|
||||
async register(username, email, password) {
|
||||
const user = await this.usersService.create(username, email, password);
|
||||
const payload = { username: user.username, sub: user.id };
|
||||
return {
|
||||
access_token: this.jwtService.sign(payload),
|
||||
user,
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.AuthService = AuthService;
|
||||
exports.AuthService = AuthService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService,
|
||||
jwt_1.JwtService])
|
||||
], AuthService);
|
||||
//# sourceMappingURL=auth.service.js.map
|
1
backend/dist/modules/auth/auth.service.js.map
vendored
Normal file
1
backend/dist/modules/auth/auth.service.js.map
v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GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;QAC1D,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;YAC3C,IAAI;SACL,CAAC;IACJ,CAAC;CACF,CAAA;AAnCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAGa,4BAAY;QACd,gBAAU;GAHrB,WAAW,CAmCvB"}
|
1
backend/dist/modules/auth/decorators/current-user.decorator.d.ts
vendored
Normal file
1
backend/dist/modules/auth/decorators/current-user.decorator.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
10
backend/dist/modules/auth/decorators/current-user.decorator.js
vendored
Normal file
10
backend/dist/modules/auth/decorators/current-user.decorator.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CurrentUser = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
exports.CurrentUser = (0, common_1.createParamDecorator)((data, context) => {
|
||||
const ctx = graphql_1.GqlExecutionContext.create(context);
|
||||
return ctx.getContext().req.user;
|
||||
});
|
||||
//# sourceMappingURL=current-user.decorator.js.map
|
1
backend/dist/modules/auth/decorators/current-user.decorator.js.map
vendored
Normal file
1
backend/dist/modules/auth/decorators/current-user.decorator.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../../../src/modules/auth/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,6CAAsD;AAEzC,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,OAAyB,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;AACnC,CAAC,CACF,CAAC"}
|
6
backend/dist/modules/auth/guards/gql-auth.guard.d.ts
vendored
Normal file
6
backend/dist/modules/auth/guards/gql-auth.guard.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import { ExecutionContext } from '@nestjs/common';
|
||||
declare const GqlAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
||||
export declare class GqlAuthGuard extends GqlAuthGuard_base {
|
||||
getRequest(context: ExecutionContext): any;
|
||||
}
|
||||
export {};
|
23
backend/dist/modules/auth/guards/gql-auth.guard.js
vendored
Normal file
23
backend/dist/modules/auth/guards/gql-auth.guard.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GqlAuthGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
let GqlAuthGuard = class GqlAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
||||
getRequest(context) {
|
||||
const ctx = graphql_1.GqlExecutionContext.create(context);
|
||||
return ctx.getContext().req;
|
||||
}
|
||||
};
|
||||
exports.GqlAuthGuard = GqlAuthGuard;
|
||||
exports.GqlAuthGuard = GqlAuthGuard = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], GqlAuthGuard);
|
||||
//# sourceMappingURL=gql-auth.guard.js.map
|
1
backend/dist/modules/auth/guards/gql-auth.guard.js.map
vendored
Normal file
1
backend/dist/modules/auth/guards/gql-auth.guard.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"gql-auth.guard.js","sourceRoot":"","sources":["../../../../src/modules/auth/guards/gql-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8D;AAC9D,+CAA6C;AAC7C,6CAAsD;AAG/C,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;IAChD,UAAU,CAAC,OAAyB;QAClC,MAAM,GAAG,GAAG,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC;IAC9B,CAAC;CACF,CAAA;AALY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CAKxB"}
|
11
backend/dist/modules/auth/strategies/jwt.strategy.d.ts
vendored
Normal file
11
backend/dist/modules/auth/strategies/jwt.strategy.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import { Strategy } from 'passport-jwt';
|
||||
import { UsersService } from '../../users/users.service';
|
||||
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
|
||||
validate(...args: any[]): unknown;
|
||||
};
|
||||
export declare class JwtStrategy extends JwtStrategy_base {
|
||||
private usersService;
|
||||
constructor(usersService: UsersService);
|
||||
validate(payload: any): Promise<import("../../users/entities/user.entity").User>;
|
||||
}
|
||||
export {};
|
37
backend/dist/modules/auth/strategies/jwt.strategy.js
vendored
Normal file
37
backend/dist/modules/auth/strategies/jwt.strategy.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JwtStrategy = void 0;
|
||||
const passport_jwt_1 = require("passport-jwt");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const users_service_1 = require("../../users/users.service");
|
||||
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
||||
usersService;
|
||||
constructor(usersService) {
|
||||
super({
|
||||
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
ignoreExpiration: false,
|
||||
secretOrKey: process.env.JWT_SECRET || 'secret',
|
||||
});
|
||||
this.usersService = usersService;
|
||||
}
|
||||
async validate(payload) {
|
||||
const user = await this.usersService.findOne(payload.sub);
|
||||
return user;
|
||||
}
|
||||
};
|
||||
exports.JwtStrategy = JwtStrategy;
|
||||
exports.JwtStrategy = JwtStrategy = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService])
|
||||
], JwtStrategy);
|
||||
//# sourceMappingURL=jwt.strategy.js.map
|
1
backend/dist/modules/auth/strategies/jwt.strategy.js.map
vendored
Normal file
1
backend/dist/modules/auth/strategies/jwt.strategy.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../../../src/modules/auth/strategies/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoD;AACpD,+CAAoD;AACpD,2CAA4C;AAC5C,6DAAyD;AAGlD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IACrC;IAApB,YAAoB,YAA0B;QAC5C,KAAK,CAAC;YACJ,cAAc,EAAE,yBAAU,CAAC,2BAA2B,EAAE;YACxD,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,QAAQ;SAChD,CAAC,CAAC;QALe,iBAAY,GAAZ,YAAY,CAAc;IAM9C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAY;QACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAbY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEuB,4BAAY;GADnC,WAAW,CAavB"}
|
2
backend/dist/modules/conversations/conversations.module.d.ts
vendored
Normal file
2
backend/dist/modules/conversations/conversations.module.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare class ConversationsModule {
|
||||
}
|
25
backend/dist/modules/conversations/conversations.module.js
vendored
Normal file
25
backend/dist/modules/conversations/conversations.module.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConversationsModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const conversations_service_1 = require("./conversations.service");
|
||||
const conversations_resolver_1 = require("./conversations.resolver");
|
||||
const conversation_entity_1 = require("./entities/conversation.entity");
|
||||
let ConversationsModule = class ConversationsModule {
|
||||
};
|
||||
exports.ConversationsModule = ConversationsModule;
|
||||
exports.ConversationsModule = ConversationsModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([conversation_entity_1.Conversation])],
|
||||
providers: [conversations_resolver_1.ConversationsResolver, conversations_service_1.ConversationsService],
|
||||
exports: [conversations_service_1.ConversationsService],
|
||||
})
|
||||
], ConversationsModule);
|
||||
//# sourceMappingURL=conversations.module.js.map
|
1
backend/dist/modules/conversations/conversations.module.js.map
vendored
Normal file
1
backend/dist/modules/conversations/conversations.module.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"conversations.module.js","sourceRoot":"","sources":["../../../src/modules/conversations/conversations.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,mEAA+D;AAC/D,qEAAiE;AACjE,wEAA8D;AAOvD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,kDAAmB;8BAAnB,mBAAmB;IAL/B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kCAAY,CAAC,CAAC,CAAC;QACnD,SAAS,EAAE,CAAC,8CAAqB,EAAE,4CAAoB,CAAC;QACxD,OAAO,EAAE,CAAC,4CAAoB,CAAC;KAChC,CAAC;GACW,mBAAmB,CAAG"}
|
11
backend/dist/modules/conversations/conversations.resolver.d.ts
vendored
Normal file
11
backend/dist/modules/conversations/conversations.resolver.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import { ConversationsService } from './conversations.service';
|
||||
import { Conversation } from './entities/conversation.entity';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
export declare class ConversationsResolver {
|
||||
private readonly conversationsService;
|
||||
constructor(conversationsService: ConversationsService);
|
||||
findAll(user: User): Promise<Conversation[]>;
|
||||
findOne(id: string, user: User): Promise<Conversation>;
|
||||
createConversation(user: User, participantIds: string[], name?: string): Promise<Conversation>;
|
||||
createPrivateConversation(user: User, recipientId: string): Promise<Conversation>;
|
||||
}
|
82
backend/dist/modules/conversations/conversations.resolver.js
vendored
Normal file
82
backend/dist/modules/conversations/conversations.resolver.js
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConversationsResolver = void 0;
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const conversations_service_1 = require("./conversations.service");
|
||||
const conversation_entity_1 = require("./entities/conversation.entity");
|
||||
const gql_auth_guard_1 = require("../auth/guards/gql-auth.guard");
|
||||
const current_user_decorator_1 = require("../auth/decorators/current-user.decorator");
|
||||
const user_entity_1 = require("../users/entities/user.entity");
|
||||
let ConversationsResolver = class ConversationsResolver {
|
||||
conversationsService;
|
||||
constructor(conversationsService) {
|
||||
this.conversationsService = conversationsService;
|
||||
}
|
||||
findAll(user) {
|
||||
return this.conversationsService.findAllForUser(user.id);
|
||||
}
|
||||
findOne(id, user) {
|
||||
return this.conversationsService.findOne(id, user.id);
|
||||
}
|
||||
createConversation(user, participantIds, name) {
|
||||
const isGroup = participantIds.length > 1;
|
||||
const allParticipantIds = [...participantIds, user.id];
|
||||
const participants = allParticipantIds.map(id => ({ id }));
|
||||
return this.conversationsService.create(participants, name, isGroup);
|
||||
}
|
||||
createPrivateConversation(user, recipientId) {
|
||||
return this.conversationsService.findOrCreatePrivate(user.id, recipientId);
|
||||
}
|
||||
};
|
||||
exports.ConversationsResolver = ConversationsResolver;
|
||||
__decorate([
|
||||
(0, graphql_1.Query)(() => [conversation_entity_1.Conversation], { name: 'conversations' }),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ConversationsResolver.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Query)(() => conversation_entity_1.Conversation, { name: 'conversation' }),
|
||||
__param(0, (0, graphql_1.Args)('id', { type: () => graphql_1.ID })),
|
||||
__param(1, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, user_entity_1.User]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ConversationsResolver.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => conversation_entity_1.Conversation),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, graphql_1.Args)('participantIds', { type: () => [graphql_1.ID] })),
|
||||
__param(2, (0, graphql_1.Args)('name', { nullable: true })),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User, Array, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ConversationsResolver.prototype, "createConversation", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => conversation_entity_1.Conversation),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, graphql_1.Args)('recipientId', { type: () => graphql_1.ID })),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ConversationsResolver.prototype, "createPrivateConversation", null);
|
||||
exports.ConversationsResolver = ConversationsResolver = __decorate([
|
||||
(0, graphql_1.Resolver)(() => conversation_entity_1.Conversation),
|
||||
(0, common_1.UseGuards)(gql_auth_guard_1.GqlAuthGuard),
|
||||
__metadata("design:paramtypes", [conversations_service_1.ConversationsService])
|
||||
], ConversationsResolver);
|
||||
//# sourceMappingURL=conversations.resolver.js.map
|
1
backend/dist/modules/conversations/conversations.resolver.js.map
vendored
Normal file
1
backend/dist/modules/conversations/conversations.resolver.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"conversations.resolver.js","sourceRoot":"","sources":["../../../src/modules/conversations/conversations.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAsE;AACtE,2CAA2C;AAC3C,mEAA+D;AAC/D,wEAA8D;AAC9D,kEAA6D;AAC7D,sFAAwE;AACxE,+DAAqD;AAI9C,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACH;IAA7B,YAA6B,oBAA0C;Q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,GAAG,EAAE,CAAC,YAAE,EAAE,CAAC,CAAA;IAC9B,WAAA,IAAA,oCAAW,GAAE,CAAA;;6CAAO,kBAAI;;oDAG1B;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kCAAY,CAAC;IAE1B,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAI,EAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,YAAE,CAAC,EAAE,CAAC,CAAA;IAC5C,WAAA,IAAA,cAAI,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;qCAFZ,kBAAI;;+DAS1B;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kCAAY,CAAC;IAE1B,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAI,EAAC,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,YAAE,EAAE,CAAC,CAAA;;qCADnB,kBAAI;;sEAI1B;gCAnCU,qBAAqB;IAFjC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kCAAY,CAAC;IAC5B,IAAA,kBAAS,EAAC,6BAAY,CAAC;qCAE6B,4CAAoB;GAD5D,qBAAqB,CAoCjC"}
|
12
backend/dist/modules/conversations/conversations.service.d.ts
vendored
Normal file
12
backend/dist/modules/conversations/conversations.service.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import { Repository } from 'typeorm';
|
||||
import { Conversation } from './entities/conversation.entity';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
export declare class ConversationsService {
|
||||
private conversationsRepository;
|
||||
constructor(conversationsRepository: Repository<Conversation>);
|
||||
create(participants: User[], name?: string, isGroup?: boolean): Promise<Conversation>;
|
||||
findAllForUser(userId: string): Promise<Conversation[]>;
|
||||
findOne(id: string, userId: string): Promise<Conversation>;
|
||||
findOrCreatePrivate(user1Id: string, user2Id: string): Promise<Conversation>;
|
||||
addParticipant(conversationId: string, userId: string, participantId: string): Promise<Conversation>;
|
||||
}
|
89
backend/dist/modules/conversations/conversations.service.js
vendored
Normal file
89
backend/dist/modules/conversations/conversations.service.js
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConversationsService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const conversation_entity_1 = require("./entities/conversation.entity");
|
||||
let ConversationsService = class ConversationsService {
|
||||
conversationsRepository;
|
||||
constructor(conversationsRepository) {
|
||||
this.conversationsRepository = conversationsRepository;
|
||||
}
|
||||
async create(participants, name, isGroup = false) {
|
||||
const conversation = this.conversationsRepository.create({
|
||||
participants,
|
||||
name,
|
||||
isGroup,
|
||||
});
|
||||
return this.conversationsRepository.save(conversation);
|
||||
}
|
||||
async findAllForUser(userId) {
|
||||
return this.conversationsRepository
|
||||
.createQueryBuilder('conversation')
|
||||
.leftJoinAndSelect('conversation.participants', 'participants')
|
||||
.leftJoinAndSelect('conversation.messages', 'messages')
|
||||
.leftJoin('conversation.participants', 'user')
|
||||
.where('user.id = :userId', { userId })
|
||||
.orderBy('messages.createdAt', 'DESC')
|
||||
.getMany();
|
||||
}
|
||||
async findOne(id, userId) {
|
||||
const conversation = await this.conversationsRepository
|
||||
.createQueryBuilder('conversation')
|
||||
.leftJoinAndSelect('conversation.participants', 'participants')
|
||||
.leftJoinAndSelect('conversation.messages', 'messages')
|
||||
.leftJoinAndSelect('messages.sender', 'sender')
|
||||
.where('conversation.id = :id', { id })
|
||||
.orderBy('messages.createdAt', 'ASC')
|
||||
.getOne();
|
||||
if (!conversation) {
|
||||
throw new common_1.NotFoundException('Беседа не найдена');
|
||||
}
|
||||
const isParticipant = conversation.participants.some(p => p.id === userId);
|
||||
if (!isParticipant) {
|
||||
throw new common_1.ForbiddenException('Вы не являетесь участником этой беседы');
|
||||
}
|
||||
return conversation;
|
||||
}
|
||||
async findOrCreatePrivate(user1Id, user2Id) {
|
||||
const existingConversation = await this.conversationsRepository
|
||||
.createQueryBuilder('conversation')
|
||||
.leftJoin('conversation.participants', 'p1')
|
||||
.leftJoin('conversation.participants', 'p2')
|
||||
.where('conversation.isGroup = false')
|
||||
.andWhere('p1.id = :user1Id', { user1Id })
|
||||
.andWhere('p2.id = :user2Id', { user2Id })
|
||||
.getOne();
|
||||
if (existingConversation) {
|
||||
return existingConversation;
|
||||
}
|
||||
return this.create([], undefined, false);
|
||||
}
|
||||
async addParticipant(conversationId, userId, participantId) {
|
||||
const conversation = await this.findOne(conversationId, userId);
|
||||
if (!conversation.isGroup) {
|
||||
throw new common_1.ForbiddenException('Нельзя добавлять участников в приватные беседы');
|
||||
}
|
||||
return conversation;
|
||||
}
|
||||
};
|
||||
exports.ConversationsService = ConversationsService;
|
||||
exports.ConversationsService = ConversationsService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(conversation_entity_1.Conversation)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository])
|
||||
], ConversationsService);
|
||||
//# sourceMappingURL=conversations.service.js.map
|
1
backend/dist/modules/conversations/conversations.service.js.map
vendored
Normal file
1
backend/dist/modules/conversations/conversations.service.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"conversations.service.js","sourceRoot":"","sources":["../../../src/modules/conversations/conversations.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,6CAAmD;AACnD,qCAAqC;AACrC,wEAA8D;AAIvD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAGrB;IAFV,YAEU,uBAAiD;QAAjD,4BAAuB,GAAvB,uBAAuB,CAA0B;IACxD,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,YAAoB,EAAE,IAAa,EAAE,OAAO,GAAG,KAAK;QAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC;YACvD,YAAY;YACZ,IAAI;YACJ,OAAO;SACR,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc;QACjC,OAAO,IAAI,CAAC,uBAAuB;aAChC,kBAAkB,CAAC,cAAc,CAAC;aAClC,iBAAiB,CAAC,2BAA2B,EAAE,cAAc,CAAC;aAC9D,iBAAiB,CAAC,uBAAuB,EAAE,UAAU,CAAC;aACtD,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;aAC7C,KAAK,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,CAAC;aACtC,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC;aACrC,OAAO,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,MAAc;QACtC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,uBAAuB;aACpD,kBAAkB,CAAC,cAAc,CAAC;aAClC,iBAAiB,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c,EAAE,aAAqB;QAChF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAEhE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC1B,MAAM,IAAI,2BAAkB,CAAC,gDAAgD,CAAC,CAAC;QACjF,CAAC;QAGD,OAAO,YAAY,CAAC;IACtB,CAAC;CACF,CAAA;AA5EY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;qCACE,oBAAU;GAHlC,oBAAoB,CA4EhC"}
|
12
backend/dist/modules/conversations/entities/conversation.entity.d.ts
vendored
Normal file
12
backend/dist/modules/conversations/entities/conversation.entity.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
import { Message } from '../../messages/entities/message.entity';
|
||||
export declare class Conversation {
|
||||
id: string;
|
||||
name?: string;
|
||||
isGroup: boolean;
|
||||
participants: User[];
|
||||
messages: Message[];
|
||||
lastMessage?: Message;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
76
backend/dist/modules/conversations/entities/conversation.entity.js
vendored
Normal file
76
backend/dist/modules/conversations/entities/conversation.entity.js
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Conversation = void 0;
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const typeorm_1 = require("typeorm");
|
||||
const user_entity_1 = require("../../users/entities/user.entity");
|
||||
const message_entity_1 = require("../../messages/entities/message.entity");
|
||||
let Conversation = class Conversation {
|
||||
id;
|
||||
name;
|
||||
isGroup;
|
||||
participants;
|
||||
messages;
|
||||
lastMessage;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
};
|
||||
exports.Conversation = Conversation;
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => graphql_1.ID),
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
||||
__metadata("design:type", String)
|
||||
], Conversation.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => String, { nullable: true }),
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], Conversation.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Boolean),
|
||||
(0, typeorm_1.Column)({ default: false }),
|
||||
__metadata("design:type", Boolean)
|
||||
], Conversation.prototype, "isGroup", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => [user_entity_1.User]),
|
||||
(0, typeorm_1.ManyToMany)(() => user_entity_1.User),
|
||||
(0, typeorm_1.JoinTable)({
|
||||
name: 'conversation_participants',
|
||||
joinColumn: { name: 'conversationId', referencedColumnName: 'id' },
|
||||
inverseJoinColumn: { name: 'userId', referencedColumnName: 'id' },
|
||||
}),
|
||||
__metadata("design:type", Array)
|
||||
], Conversation.prototype, "participants", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => [message_entity_1.Message]),
|
||||
(0, typeorm_1.OneToMany)(() => message_entity_1.Message, message => message.conversation),
|
||||
__metadata("design:type", Array)
|
||||
], Conversation.prototype, "messages", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => message_entity_1.Message, { nullable: true }),
|
||||
__metadata("design:type", message_entity_1.Message)
|
||||
], Conversation.prototype, "lastMessage", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date),
|
||||
(0, typeorm_1.CreateDateColumn)(),
|
||||
__metadata("design:type", Date)
|
||||
], Conversation.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date),
|
||||
(0, typeorm_1.UpdateDateColumn)(),
|
||||
__metadata("design:type", Date)
|
||||
], Conversation.prototype, "updatedAt", void 0);
|
||||
exports.Conversation = Conversation = __decorate([
|
||||
(0, graphql_1.ObjectType)(),
|
||||
(0, typeorm_1.Entity)('conversations')
|
||||
], Conversation);
|
||||
//# sourceMappingURL=conversation.entity.js.map
|
1
backend/dist/modules/conversations/entities/conversation.entity.js.map
vendored
Normal file
1
backend/dist/modules/conversations/entities/conversation.entity.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"conversation.entity.js","sourceRoot":"","sources":["../../../../src/modules/conversations/entities/conversation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAwD;AACxD,qCAAuI;AACvI,kEAAwD;AACxD,2EAAiE;AAI1D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGvB,EAAE,CAAS;IAIX,IAAI,CAAU;IAId,OAAO,CAAU;IASjB,YAAY,CAAS;IAIrB,QAAQ,CAAY;IAGpB,WAAW,CAAW;IAItB,SAAS,CAAO;IAIhB,SAAS,CAAO;CACjB,CAAA;AApCY,oCAAY;AAGvB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,YAAE,CAAC;IACf,IAAA,gCAAsB,EAAC,MAAM,CAAC;;wCACpB;AAIX;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,gBA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d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
import { Conversation } from '../../conversations/entities/conversation.entity';
|
||||
export declare class Message {
|
||||
id: string;
|
||||
content: string;
|
||||
sender: User;
|
||||
conversation: Conversation;
|
||||
isRead: boolean;
|
||||
isEdited: boolean;
|
||||
editedAt?: Date;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
78
backend/dist/modules/messages/entities/message.entity.js
vendored
Normal file
78
backend/dist/modules/messages/entities/message.entity.js
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Message = void 0;
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const typeorm_1 = require("typeorm");
|
||||
const user_entity_1 = require("../../users/entities/user.entity");
|
||||
const conversation_entity_1 = require("../../conversations/entities/conversation.entity");
|
||||
let Message = class Message {
|
||||
id;
|
||||
content;
|
||||
sender;
|
||||
conversation;
|
||||
isRead;
|
||||
isEdited;
|
||||
editedAt;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
};
|
||||
exports.Message = Message;
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => graphql_1.ID),
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
||||
__metadata("design:type", String)
|
||||
], Message.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(),
|
||||
(0, typeorm_1.Column)('text'),
|
||||
__metadata("design:type", String)
|
||||
], Message.prototype, "content", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => user_entity_1.User),
|
||||
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, user => user.messages),
|
||||
__metadata("design:type", user_entity_1.User)
|
||||
], Message.prototype, "sender", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => conversation_entity_1.Conversation),
|
||||
(0, typeorm_1.ManyToOne)(() => conversation_entity_1.Conversation, conversation => conversation.messages),
|
||||
__metadata("design:type", conversation_entity_1.Conversation)
|
||||
], Message.prototype, "conversation", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Boolean),
|
||||
(0, typeorm_1.Column)({ default: false }),
|
||||
__metadata("design:type", Boolean)
|
||||
], Message.prototype, "isRead", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Boolean),
|
||||
(0, typeorm_1.Column)({ default: false }),
|
||||
__metadata("design:type", Boolean)
|
||||
], Message.prototype, "isEdited", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date, { nullable: true }),
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", Date)
|
||||
], Message.prototype, "editedAt", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date),
|
||||
(0, typeorm_1.CreateDateColumn)(),
|
||||
__metadata("design:type", Date)
|
||||
], Message.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date),
|
||||
(0, typeorm_1.UpdateDateColumn)(),
|
||||
__metadata("design:type", Date)
|
||||
], Message.prototype, "updatedAt", void 0);
|
||||
exports.Message = Message = __decorate([
|
||||
(0, graphql_1.ObjectType)(),
|
||||
(0, typeorm_1.Entity)('messages')
|
||||
], Message);
|
||||
//# sourceMappingURL=message.entity.js.map
|
1
backend/dist/modules/messages/entities/message.entity.js.map
vendored
Normal file
1
backend/dist/modules/messages/entities/message.entity.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"message.entity.js","sourceRoot":"","sources":["../../../../src/modules/messages/entities/message.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAwD;AACxD,qCAAgH;AAChH,kEAAwD;AACxD,0FAAgF;AAIzE,IAAM,OAAO,GAAb,MAAM,OAAO;IAGlB,EAAE,CAAS;IAIX,OAAO,CAAS;IAIhB,MAAM,CAAO;IAIb,YAAY,CAAe;IAI3B,MAAM,CAAU;IAIhB,QAAQ,CAAU;IAIlB,QAAQ,CAAQ;IAIhB,SAAS,CAAO;IAIhB,SAAS,CAAO;CACjB,CAAA;AApCY,0BAAO;AAGlB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,YAAE,CAAC;IACf,IAAA,gCAAsB,EAAC,MAAM,CAAC;;mCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,MAAM,CAAC;;wCACC;AAIhB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACjB,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;8BACrC,kBAAI;uCAAC;AAIb;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kCAAY,CAAC;IACzB,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kCAAY,EAAE,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC;8BACvD,kCAAY;6CAAC;AAI3B;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IACpB,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;uCACX;AAIhB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IACpB,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;yCACT;AAIlB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BAChB,IAAI;yCAAC;AAIhB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IACjB,IAAA,0BAAgB,GAAE;8BACR,IAAI;0CAAC;AAIhB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IACjB,IAAA,0BAAgB,GAAE;8BACR,IAAI;0CAAC;kBAnCL,OAAO;IAFnB,IAAA,oBAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,UAAU,CAAC;GACN,OAAO,CAoCnB"}
|
2
backend/dist/modules/messages/messages.module.d.ts
vendored
Normal file
2
backend/dist/modules/messages/messages.module.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare class MessagesModule {
|
||||
}
|
29
backend/dist/modules/messages/messages.module.js
vendored
Normal file
29
backend/dist/modules/messages/messages.module.js
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MessagesModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const messages_service_1 = require("./messages.service");
|
||||
const messages_resolver_1 = require("./messages.resolver");
|
||||
const message_entity_1 = require("./entities/message.entity");
|
||||
const conversations_module_1 = require("../conversations/conversations.module");
|
||||
let MessagesModule = class MessagesModule {
|
||||
};
|
||||
exports.MessagesModule = MessagesModule;
|
||||
exports.MessagesModule = MessagesModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
typeorm_1.TypeOrmModule.forFeature([message_entity_1.Message]),
|
||||
conversations_module_1.ConversationsModule,
|
||||
],
|
||||
providers: [messages_resolver_1.MessagesResolver, messages_service_1.MessagesService],
|
||||
exports: [messages_service_1.MessagesService],
|
||||
})
|
||||
], MessagesModule);
|
||||
//# sourceMappingURL=messages.module.js.map
|
1
backend/dist/modules/messages/messages.module.js.map
vendored
Normal file
1
backend/dist/modules/messages/messages.module.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"messages.module.js","sourceRoot":"","sources":["../../../src/modules/messages/messages.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,yDAAqD;AACrD,2DAAuD;AACvD,8DAAoD;AACpD,gFAA4E;AAUrE,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAR1B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,wBAAO,CAAC,CAAC;YACnC,0CAAmB;SACpB;QACD,SAAS,EAAE,CAAC,oCAAgB,EAAE,kCAAe,CAAC;QAC9C,OAAO,EAAE,CAAC,kCAAe,CAAC;KAC3B,CAAC;GACW,cAAc,CAAG"}
|
13
backend/dist/modules/messages/messages.resolver.d.ts
vendored
Normal file
13
backend/dist/modules/messages/messages.resolver.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { MessagesService } from './messages.service';
|
||||
import { Message } from './entities/message.entity';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
export declare class MessagesResolver {
|
||||
private readonly messagesService;
|
||||
constructor(messagesService: MessagesService);
|
||||
findAll(conversationId: string, user: User): Promise<Message[]>;
|
||||
sendMessage(user: User, conversationId: string, content: string): Promise<Message>;
|
||||
updateMessage(user: User, messageId: string, content: string): Promise<Message>;
|
||||
deleteMessage(user: User, messageId: string): Promise<boolean>;
|
||||
markMessageAsRead(user: User, messageId: string): Promise<Message>;
|
||||
messageAdded(conversationId: string): any;
|
||||
}
|
110
backend/dist/modules/messages/messages.resolver.js
vendored
Normal file
110
backend/dist/modules/messages/messages.resolver.js
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MessagesResolver = void 0;
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const graphql_subscriptions_1 = require("graphql-subscriptions");
|
||||
const messages_service_1 = require("./messages.service");
|
||||
const message_entity_1 = require("./entities/message.entity");
|
||||
const gql_auth_guard_1 = require("../auth/guards/gql-auth.guard");
|
||||
const current_user_decorator_1 = require("../auth/decorators/current-user.decorator");
|
||||
const user_entity_1 = require("../users/entities/user.entity");
|
||||
const pubSub = new graphql_subscriptions_1.PubSub();
|
||||
let MessagesResolver = class MessagesResolver {
|
||||
messagesService;
|
||||
constructor(messagesService) {
|
||||
this.messagesService = messagesService;
|
||||
}
|
||||
findAll(conversationId, user) {
|
||||
return this.messagesService.findAllInConversation(conversationId, user.id);
|
||||
}
|
||||
async sendMessage(user, conversationId, content) {
|
||||
const message = await this.messagesService.create(conversationId, user.id, content);
|
||||
pubSub.publish('messageAdded', { messageAdded: message });
|
||||
return message;
|
||||
}
|
||||
updateMessage(user, messageId, content) {
|
||||
return this.messagesService.update(messageId, user.id, content);
|
||||
}
|
||||
deleteMessage(user, messageId) {
|
||||
return this.messagesService.delete(messageId, user.id);
|
||||
}
|
||||
markMessageAsRead(user, messageId) {
|
||||
return this.messagesService.markAsRead(messageId, user.id);
|
||||
}
|
||||
messageAdded(conversationId) {
|
||||
return pubSub.asyncIterator('messageAdded');
|
||||
}
|
||||
};
|
||||
exports.MessagesResolver = MessagesResolver;
|
||||
__decorate([
|
||||
(0, graphql_1.Query)(() => [message_entity_1.Message], { name: 'messages' }),
|
||||
__param(0, (0, graphql_1.Args)('conversationId', { type: () => graphql_1.ID })),
|
||||
__param(1, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, user_entity_1.User]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MessagesResolver.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => message_entity_1.Message),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, graphql_1.Args)('conversationId', { type: () => graphql_1.ID })),
|
||||
__param(2, (0, graphql_1.Args)('content')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User, String, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MessagesResolver.prototype, "sendMessage", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => message_entity_1.Message),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, graphql_1.Args)('messageId', { type: () => graphql_1.ID })),
|
||||
__param(2, (0, graphql_1.Args)('content')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User, String, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MessagesResolver.prototype, "updateMessage", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => Boolean),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, graphql_1.Args)('messageId', { type: () => graphql_1.ID })),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MessagesResolver.prototype, "deleteMessage", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => message_entity_1.Message),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, graphql_1.Args)('messageId', { type: () => graphql_1.ID })),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MessagesResolver.prototype, "markMessageAsRead", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Subscription)(() => message_entity_1.Message, {
|
||||
filter: (payload, variables) => {
|
||||
return payload.messageAdded.conversation.id === variables.conversationId;
|
||||
},
|
||||
}),
|
||||
__param(0, (0, graphql_1.Args)('conversationId', { type: () => graphql_1.ID })),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MessagesResolver.prototype, "messageAdded", null);
|
||||
exports.MessagesResolver = MessagesResolver = __decorate([
|
||||
(0, graphql_1.Resolver)(() => message_entity_1.Message),
|
||||
(0, common_1.UseGuards)(gql_auth_guard_1.GqlAuthGuard),
|
||||
__metadata("design:paramtypes", [messages_service_1.MessagesService])
|
||||
], MessagesResolver);
|
||||
//# sourceMappingURL=messages.resolver.js.map
|
1
backend/dist/modules/messages/messages.resolver.js.map
vendored
Normal file
1
backend/dist/modules/messages/messages.resolver.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"messages.resolver.js","sourceRoot":"","sources":["../../../src/modules/messages/messages.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAoF;AACpF,2CAA2C;AAC3C,iEAA+C;AAC/C,yDAAqD;AACrD,8DAAoD;AACpD,kEAA6D;AAC7D,sFAAwE;AACxE,+DAAqD;AAErD,MAAM,MAAM,GAAG,IAAI,8BAAM,EAAE,CAAC;AAIrB,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACE;IAA7B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAGjE,OAAO,CACuC,cAAsB,EACnD,IAAU;QAEzB,OAAO,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CACA,IAAU,EACmB,cAAsB,EACjD,OAAe;QAEhC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAGpF,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;QAE1D,OAAO,OAAO,CAAC;IACjB,CAAC;IAGD,aAAa,CACI,IAAU,EACc,SAAiB,EACvC,OAAe;QAEhC,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAA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CAAA;;qCAFK,kBAAI;;qDAK1B;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IAErB,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAI,EAAC,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,YAAE,EAAE,CAAC,CAAA;;qCADjB,kBAAI;;qDAI1B;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,wBAAO,CAAC;IAErB,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAI,EAAC,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,YAAE,EAAE,CAAC,CAAA;;qCADjB,kBAAI;;yDAI1B;AAOD;IALC,IAAA,sBAAY,EAAC,GAAG,EAAE,CAAC,wBAAO,EAAE;QAC3B,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE;YAC7B,OAAO,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,CAAC,cAAc,CAAC;QAC3E,CAAC;KACF,CAAC;IACY,WAAA,IAAA,cAAI,EAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,YAAE,EAAE,CAAC,CAAA;;;;oDAEvD;2BAzDU,gBAAgB;IAF5B,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,wBAAO,CAAC;IACvB,IAAA,kBAAS,EAAC,6BAAY,CAAC;qCAEwB,kCAAe;GADlD,gBAAgB,CA0D5B"}
|
13
backend/dist/modules/messages/messages.service.d.ts
vendored
Normal file
13
backend/dist/modules/messages/messages.service.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { Repository } from 'typeorm';
|
||||
import { Message } from './entities/message.entity';
|
||||
import { ConversationsService } from '../conversations/conversations.service';
|
||||
export declare class MessagesService {
|
||||
private messagesRepository;
|
||||
private conversationsService;
|
||||
constructor(messagesRepository: Repository<Message>, conversationsService: ConversationsService);
|
||||
create(conversationId: string, senderId: string, content: string): Promise<Message>;
|
||||
findAllInConversation(conversationId: string, userId: string): Promise<Message[]>;
|
||||
update(messageId: string, userId: string, content: string): Promise<Message>;
|
||||
markAsRead(messageId: string, userId: string): Promise<Message>;
|
||||
delete(messageId: string, userId: string): Promise<boolean>;
|
||||
}
|
98
backend/dist/modules/messages/messages.service.js
vendored
Normal file
98
backend/dist/modules/messages/messages.service.js
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MessagesService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const message_entity_1 = require("./entities/message.entity");
|
||||
const conversations_service_1 = require("../conversations/conversations.service");
|
||||
let MessagesService = class MessagesService {
|
||||
messagesRepository;
|
||||
conversationsService;
|
||||
constructor(messagesRepository, conversationsService) {
|
||||
this.messagesRepository = messagesRepository;
|
||||
this.conversationsService = conversationsService;
|
||||
}
|
||||
async create(conversationId, senderId, content) {
|
||||
const conversation = await this.conversationsService.findOne(conversationId, senderId);
|
||||
const message = this.messagesRepository.create({
|
||||
content,
|
||||
sender: { id: senderId },
|
||||
conversation: { id: conversationId },
|
||||
});
|
||||
return this.messagesRepository.save(message);
|
||||
}
|
||||
async findAllInConversation(conversationId, userId) {
|
||||
await this.conversationsService.findOne(conversationId, userId);
|
||||
return this.messagesRepository.find({
|
||||
where: { conversation: { id: conversationId } },
|
||||
relations: ['sender'],
|
||||
order: { createdAt: 'ASC' },
|
||||
});
|
||||
}
|
||||
async update(messageId, userId, content) {
|
||||
const message = await this.messagesRepository.findOne({
|
||||
where: { id: messageId },
|
||||
relations: ['sender'],
|
||||
});
|
||||
if (!message) {
|
||||
throw new common_1.NotFoundException('Сообщение не найдено');
|
||||
}
|
||||
if (message.sender.id !== userId) {
|
||||
throw new common_1.ForbiddenException('Вы можете редактировать только свои сообщения');
|
||||
}
|
||||
message.content = content;
|
||||
message.isEdited = true;
|
||||
message.editedAt = new Date();
|
||||
return this.messagesRepository.save(message);
|
||||
}
|
||||
async markAsRead(messageId, userId) {
|
||||
const message = await this.messagesRepository.findOne({
|
||||
where: { id: messageId },
|
||||
relations: ['conversation', 'conversation.participants'],
|
||||
});
|
||||
if (!message) {
|
||||
throw new common_1.NotFoundException('Сообщение не найдено');
|
||||
}
|
||||
const isParticipant = message.conversation.participants.some(p => p.id === userId);
|
||||
if (!isParticipant) {
|
||||
throw new common_1.ForbiddenException('Вы не являетесь участником этой беседы');
|
||||
}
|
||||
message.isRead = true;
|
||||
return this.messagesRepository.save(message);
|
||||
}
|
||||
async delete(messageId, userId) {
|
||||
const message = await this.messagesRepository.findOne({
|
||||
where: { id: messageId },
|
||||
relations: ['sender'],
|
||||
});
|
||||
if (!message) {
|
||||
throw new common_1.NotFoundException('Сообщение не найдено');
|
||||
}
|
||||
if (message.sender.id !== userId) {
|
||||
throw new common_1.ForbiddenException('Вы можете удалять только свои сообщения');
|
||||
}
|
||||
await this.messagesRepository.remove(message);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
exports.MessagesService = MessagesService;
|
||||
exports.MessagesService = MessagesService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(message_entity_1.Message)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
conversations_service_1.ConversationsService])
|
||||
], MessagesService);
|
||||
//# sourceMappingURL=messages.service.js.map
|
1
backend/dist/modules/messages/messages.service.js.map
vendored
Normal file
1
backend/dist/modules/messages/messages.service.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"messages.service.js","sourceRoot":"","sources":["../../../src/modules/messages/messages.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,6CAAmD;AACnD,qCAAqC;AACrC,8DAAoD;AACpD,kFAA8E;AAGvE,IAAM,eAAe,GAArB,MAAM,eAAe;IAGhB;IACA;IAHV,YAEU,kBAAuC,EACvC,oBAA0C;QAD1C,uBAAkB,GAAlB,kBAAkB,CAAqB;QACvC,yBAAoB,GAApB,oBAAoB,CAAsB;IACjD,CAAC;IAEJ,KAAK,CAAC,MAAM,CACV,cAAsB,EACtB,QAAgB,EAChB,OAAe;QAEf,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAEvF,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC7C,OAAO;YACP,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE;YACxB,YAAY,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE;SACrC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,cAAsB,EAAE,MAAc;QAEhE,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,c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AAM,IAAI,0BAAiB,CAAC,sBAAsB,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,2BAAkB,CAAC,wCAAwC,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,MAAc;QAC5C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YACpD,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;YACxB,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,0BAAiB,CAAC,sBAAsB,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;YACjC,MAAM,IAAI,2BAAkB,CAAC,yCAAyC,CAAC,CAAC;QAC1E,CAAC;QAED,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA3FY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,wBAAO,CAAC,CAAA;qCACE,oBAAU;QACR,4CAAoB;GAJzC,eAAe,CA2F3B"}
|
14
backend/dist/modules/users/entities/user.entity.d.ts
vendored
Normal file
14
backend/dist/modules/users/entities/user.entity.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { Message } from '../../messages/entities/message.entity';
|
||||
export declare class User {
|
||||
id: string;
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
avatar?: string;
|
||||
bio?: string;
|
||||
isOnline: boolean;
|
||||
lastSeen?: Date;
|
||||
messages: Message[];
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
89
backend/dist/modules/users/entities/user.entity.js
vendored
Normal file
89
backend/dist/modules/users/entities/user.entity.js
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.User = void 0;
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const typeorm_1 = require("typeorm");
|
||||
const message_entity_1 = require("../../messages/entities/message.entity");
|
||||
let User = class User {
|
||||
id;
|
||||
username;
|
||||
email;
|
||||
password;
|
||||
avatar;
|
||||
bio;
|
||||
isOnline;
|
||||
lastSeen;
|
||||
messages;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
};
|
||||
exports.User = User;
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => graphql_1.ID),
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(),
|
||||
(0, typeorm_1.Column)({ unique: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(),
|
||||
(0, typeorm_1.Column)({ unique: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "email", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.HideField)(),
|
||||
(0, typeorm_1.Column)(),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "password", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => String, { nullable: true }),
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "avatar", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => String, { nullable: true }),
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "bio", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Boolean),
|
||||
(0, typeorm_1.Column)({ default: false }),
|
||||
__metadata("design:type", Boolean)
|
||||
], User.prototype, "isOnline", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date, { nullable: true }),
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", Date)
|
||||
], User.prototype, "lastSeen", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => [message_entity_1.Message]),
|
||||
(0, typeorm_1.OneToMany)(() => message_entity_1.Message, message => message.sender),
|
||||
__metadata("design:type", Array)
|
||||
], User.prototype, "messages", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date),
|
||||
(0, typeorm_1.CreateDateColumn)(),
|
||||
__metadata("design:type", Date)
|
||||
], User.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
(0, graphql_1.Field)(() => Date),
|
||||
(0, typeorm_1.UpdateDateColumn)(),
|
||||
__metadata("design:type", Date)
|
||||
], User.prototype, "updatedAt", void 0);
|
||||
exports.User = User = __decorate([
|
||||
(0, graphql_1.ObjectType)(),
|
||||
(0, typeorm_1.Entity)('users')
|
||||
], User);
|
||||
//# sourceMappingURL=user.entity.js.map
|
1
backend/dist/modules/users/entities/user.entity.js.map
vendored
Normal file
1
backend/dist/modules/users/entities/user.entity.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../../src/modules/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,qCAAgH;AAChH,2EAAiE;AAI1D,IAAM,IAAI,GAAV,MAAM,IAAI;IAGf,EAAE,CAAS;IAIX,QAAQ,CAAS;IAIjB,KAAK,CAAS;IAId,QAAQ,CAAS;IAIjB,MAAM,CAAU;IAIhB,GAAG,CAAU;IAIb,QAAQ,CAAU;IAIlB,QAAQ,CAAQ;IAIhB,QAAQ,CAAY;IAIpB,SAAS,CAAO;IAIhB,SAAS,CAAO;CACjB,CAAA;AA5CY,oBAAI;AAGf;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,YAAE,CAAC;IACf,IAAA,gCAAsB,EAAC,MAAM,CAAC;;gCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;sCACR;AAIjB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;mCACX;AAId;IAFC,IAAA,mBAAS,GAAE;IACX,IAAA,gBAAM,GAAE;;sCACQ;AAIjB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCACX;AAIhB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iCACd;AAIb;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IACpB,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;sCACT;AAIlB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BAChB,IAAI;sCAAC;AAIhB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,wBAAO,CAAC,CAAC;IACtB,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAO,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;sCAChC;AAIpB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IACjB,IAAA,0BAAgB,GAAE;8BACR,IAAI;uCAAC;AAIhB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IACjB,IAAA,0BAAgB,GAAE;8BACR,IAAI;uCAAC;eA3CL,IAAI;IAFhB,IAAA,oBAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,OAAO,CAAC;GACH,IAAI,CA4ChB"}
|
2
backend/dist/modules/users/users.module.d.ts
vendored
Normal file
2
backend/dist/modules/users/users.module.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare class UsersModule {
|
||||
}
|
25
backend/dist/modules/users/users.module.js
vendored
Normal file
25
backend/dist/modules/users/users.module.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UsersModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const users_service_1 = require("./users.service");
|
||||
const users_resolver_1 = require("./users.resolver");
|
||||
const user_entity_1 = require("./entities/user.entity");
|
||||
let UsersModule = class UsersModule {
|
||||
};
|
||||
exports.UsersModule = UsersModule;
|
||||
exports.UsersModule = UsersModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User])],
|
||||
providers: [users_resolver_1.UsersResolver, users_service_1.UsersService],
|
||||
exports: [users_service_1.UsersService],
|
||||
})
|
||||
], UsersModule);
|
||||
//# sourceMappingURL=users.module.js.map
|
1
backend/dist/modules/users/users.module.js.map
vendored
Normal file
1
backend/dist/modules/users/users.module.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"users.module.js","sourceRoot":"","sources":["../../../src/modules/users/users.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,mDAA+C;AAC/C,qDAAiD;AACjD,wDAA8C;AAOvC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,CAAC,CAAC,CAAC;QAC3C,SAAS,EAAE,CAAC,8BAAa,EAAE,4BAAY,CAAC;QACxC,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
|
10
backend/dist/modules/users/users.resolver.d.ts
vendored
Normal file
10
backend/dist/modules/users/users.resolver.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { UsersService } from './users.service';
|
||||
import { User } from './entities/user.entity';
|
||||
export declare class UsersResolver {
|
||||
private readonly usersService;
|
||||
constructor(usersService: UsersService);
|
||||
findAll(): Promise<User[]>;
|
||||
findOne(id: string): Promise<User>;
|
||||
getMe(user: User): Promise<User>;
|
||||
updateUser(user: User, bio?: string, avatar?: string): Promise<User>;
|
||||
}
|
78
backend/dist/modules/users/users.resolver.js
vendored
Normal file
78
backend/dist/modules/users/users.resolver.js
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UsersResolver = void 0;
|
||||
const graphql_1 = require("@nestjs/graphql");
|
||||
const users_service_1 = require("./users.service");
|
||||
const user_entity_1 = require("./entities/user.entity");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const gql_auth_guard_1 = require("../auth/guards/gql-auth.guard");
|
||||
const current_user_decorator_1 = require("../auth/decorators/current-user.decorator");
|
||||
let UsersResolver = class UsersResolver {
|
||||
usersService;
|
||||
constructor(usersService) {
|
||||
this.usersService = usersService;
|
||||
}
|
||||
findAll() {
|
||||
return this.usersService.findAll();
|
||||
}
|
||||
findOne(id) {
|
||||
return this.usersService.findOne(id);
|
||||
}
|
||||
getMe(user) {
|
||||
return this.usersService.findOne(user.id);
|
||||
}
|
||||
updateUser(user, bio, avatar) {
|
||||
return this.usersService.update(user.id, { bio, avatar });
|
||||
}
|
||||
};
|
||||
exports.UsersResolver = UsersResolver;
|
||||
__decorate([
|
||||
(0, graphql_1.Query)(() => [user_entity_1.User], { name: 'users' }),
|
||||
(0, common_1.UseGuards)(gql_auth_guard_1.GqlAuthGuard),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersResolver.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Query)(() => user_entity_1.User, { name: 'user' }),
|
||||
(0, common_1.UseGuards)(gql_auth_guard_1.GqlAuthGuard),
|
||||
__param(0, (0, graphql_1.Args)('id', { type: () => graphql_1.ID })),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersResolver.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Query)(() => user_entity_1.User, { name: 'me' }),
|
||||
(0, common_1.UseGuards)(gql_auth_guard_1.GqlAuthGuard),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersResolver.prototype, "getMe", null);
|
||||
__decorate([
|
||||
(0, graphql_1.Mutation)(() => user_entity_1.User),
|
||||
(0, common_1.UseGuards)(gql_auth_guard_1.GqlAuthGuard),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, graphql_1.Args)('bio', { nullable: true })),
|
||||
__param(2, (0, graphql_1.Args)('avatar', { nullable: true })),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [user_entity_1.User, String, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersResolver.prototype, "updateUser", null);
|
||||
exports.UsersResolver = UsersResolver = __decorate([
|
||||
(0, graphql_1.Resolver)(() => user_entity_1.User),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService])
|
||||
], UsersResolver);
|
||||
//# sourceMappingURL=users.resolver.js.map
|
1
backend/dist/modules/users/users.resolver.js.map
vendored
Normal file
1
backend/dist/modules/users/users.resolver.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"users.resolver.js","sourceRoot":"","sources":["../../../src/modules/users/users.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAsE;AACtE,mDAA+C;AAC/C,wDAA8C;AAC9C,2CAA2C;AAC3C,kEAA6D;AAC7D,sFAAwE;AAGjE,IAAM,aAAa,GAAnB,MAAM,aAAa;IACK;IAA7B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAI3D,OAAO;QACL,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;IAID,OAAO,CAAiC,EAAU;QAChD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAID,KAAK,CAAgB,IAAU;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IAID,UAAU,CACO,IAAU,EACQ,GAAY,EACT,MAAe;QAEnD,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF,CAAA;AA9BY,sCAAa;AAKxB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,kBAAI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACtC,IAAA,kBAAS,EAAC,6BAAY,CAAC;;;;4CAGvB;AAID;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACnC,IAAA,kBAAS,EAAC,6BAAY,CAAC;IACf,WAAA,IAAA,cAAI,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,YAAE,EAAE,CAAC,CAAA;;;;4CAEtC;AAID;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACjC,IAAA,kBAAS,EAAC,6BAAY,CAAC;IACjB,WAAA,IAAA,oCAAW,GAAE,CAAA;;qCAAO,kBAAI;;0CAE9B;AAID;IAFC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACpB,IAAA,kBAAS,EAAC,6BAAY,CAAC;IAErB,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAI,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/B,WAAA,IAAA,cAAI,EAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;qCAFd,kBAAI;;+CAK1B;wBA7BU,aAAa;IADzB,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;qCAEwB,4BAAY;GAD5C,aAAa,CA8BzB"}
|
13
backend/dist/modules/users/users.service.d.ts
vendored
Normal file
13
backend/dist/modules/users/users.service.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { Repository } from 'typeorm';
|
||||
import { User } from './entities/user.entity';
|
||||
export declare class UsersService {
|
||||
private usersRepository;
|
||||
constructor(usersRepository: Repository<User>);
|
||||
create(username: string, email: string, password: string): Promise<User>;
|
||||
findAll(): Promise<User[]>;
|
||||
findOne(id: string): Promise<User>;
|
||||
findByUsername(username: string): Promise<User | null>;
|
||||
findByEmail(email: string): Promise<User | null>;
|
||||
update(id: string, updateData: Partial<User>): Promise<User>;
|
||||
updateOnlineStatus(id: string, isOnline: boolean): Promise<void>;
|
||||
}
|
107
backend/dist/modules/users/users.service.js
vendored
Normal file
107
backend/dist/modules/users/users.service.js
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UsersService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const user_entity_1 = require("./entities/user.entity");
|
||||
const bcrypt = __importStar(require("bcrypt"));
|
||||
let UsersService = class UsersService {
|
||||
usersRepository;
|
||||
constructor(usersRepository) {
|
||||
this.usersRepository = usersRepository;
|
||||
}
|
||||
async create(username, email, password) {
|
||||
const existingUser = await this.usersRepository.findOne({
|
||||
where: [{ username }, { email }],
|
||||
});
|
||||
if (existingUser) {
|
||||
throw new common_1.ConflictException('Пользователь с таким username или email уже существует');
|
||||
}
|
||||
const hashedPassword = await bcrypt.hash(password, 10);
|
||||
const user = this.usersRepository.create({
|
||||
username,
|
||||
email,
|
||||
password: hashedPassword,
|
||||
});
|
||||
return this.usersRepository.save(user);
|
||||
}
|
||||
async findAll() {
|
||||
return this.usersRepository.find();
|
||||
}
|
||||
async findOne(id) {
|
||||
const user = await this.usersRepository.findOne({ where: { id } });
|
||||
if (!user) {
|
||||
throw new common_1.NotFoundException('Пользователь не найден');
|
||||
}
|
||||
return user;
|
||||
}
|
||||
async findByUsername(username) {
|
||||
return this.usersRepository.findOne({ where: { username } });
|
||||
}
|
||||
async findByEmail(email) {
|
||||
return this.usersRepository.findOne({ where: { email } });
|
||||
}
|
||||
async update(id, updateData) {
|
||||
await this.usersRepository.update(id, updateData);
|
||||
return this.findOne(id);
|
||||
}
|
||||
async updateOnlineStatus(id, isOnline) {
|
||||
await this.usersRepository.update(id, {
|
||||
isOnline,
|
||||
lastSeen: isOnline ? null : new Date(),
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.UsersService = UsersService;
|
||||
exports.UsersService = UsersService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository])
|
||||
], UsersService);
|
||||
//# sourceMappingURL=users.service.js.map
|
1
backend/dist/modules/users/users.service.js.map
vendored
Normal file
1
backend/dist/modules/users/users.service.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../../src/modules/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAkF;AAClF,6CAAmD;AACnD,qCAAqC;AACrC,wDAA8C;AAC9C,+CAAiC;AAG1B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGb;IAFV,YAEU,eAAiC;QAAjC,oBAAe,GAAf,eAAe,CAAkB;IACxC,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,KAAa,EAAE,QAAgB;QAC5D,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;YACtD,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;SACjC,CAAC,CAAC;QAEH,IA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AAC;IAC1B,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,EAAU,EAAE,QAAiB;QACpD,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,EAAE;YACpC,QAAQ;YACR,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;SACvC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAxDY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qCACE,oBAAU;GAH1B,YAAY,CAwDxB"}
|
1
backend/dist/tsconfig.build.tsbuildinfo
vendored
Normal file
1
backend/dist/tsconfig.build.tsbuildinfo
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,18 +1,20 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
container_name: prism_postgres
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: prism_messenger
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
# Закомментировано, так как используется удаленная база данных
|
||||
# Раскомментируйте для локальной разработки
|
||||
# postgres:
|
||||
# image: postgres:15-alpine
|
||||
# container_name: prism_postgres
|
||||
# environment:
|
||||
# POSTGRES_USER: postgres
|
||||
# POSTGRES_PASSWORD: postgres
|
||||
# POSTGRES_DB: prism_messenger
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
# volumes:
|
||||
# - postgres_data:/var/lib/postgresql/data
|
||||
# restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
# volumes:
|
||||
# postgres_data:
|
Reference in New Issue
Block a user