cherif helped me fix the queryBuilder, so much better now
This commit is contained in:
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "group_transcendence",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ POSTGRES_DATABASE=transcendance_db
|
|||||||
|
|
||||||
# OAUTH2 42 API
|
# OAUTH2 42 API
|
||||||
FORTYTWO_CLIENT_ID=u-s4t2ud-49dc7b539bcfe1acb48b928b2b281671c99fc5bfab1faca57a536ab7e0075500
|
FORTYTWO_CLIENT_ID=u-s4t2ud-49dc7b539bcfe1acb48b928b2b281671c99fc5bfab1faca57a536ab7e0075500
|
||||||
FORTYTWO_CLIENT_SECRET=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
|
FORTYTWO_CLIENT_SECRET=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
|
||||||
FORTYTWO_CALLBACK_URL=http://transcendance:8080/api/v2/auth/redirect
|
FORTYTWO_CALLBACK_URL=http://transcendance:8080/api/v2/auth/redirect
|
||||||
COOKIE_SECRET=248cdc831110eec8796d7c1edbf79835
|
COOKIE_SECRET=248cdc831110eec8796d7c1edbf79835
|
||||||
# JWT
|
# JWT
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ export class FriendshipService {
|
|||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb2) => {
|
new Brackets((qb2) => {
|
||||||
qb2.where('friendship.status = :status', {status : FriendshipStatus.ACCEPTED})
|
qb2.where('friendship.status = :statusA', {statusA : FriendshipStatus.ACCEPTED})
|
||||||
// .orWhere('friendship.status = :status', {status : FriendshipStatus.REQUESTED})
|
.orWhere('friendship.status = :statusR', {statusR : FriendshipStatus.REQUESTED})
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.getOne()
|
.getOne()
|
||||||
@@ -54,34 +54,34 @@ export class FriendshipService {
|
|||||||
// console.log('MIDDLE Find one friend by username: ')
|
// console.log('MIDDLE Find one friend by username: ')
|
||||||
// console.log({...friendship})
|
// console.log({...friendship})
|
||||||
|
|
||||||
if (!friendship) {
|
// if (!friendship) {
|
||||||
friendship = await this.friendshipRepository
|
// friendship = await this.friendshipRepository
|
||||||
.createQueryBuilder('friendship')
|
// .createQueryBuilder('friendship')
|
||||||
.where(
|
// .where(
|
||||||
new Brackets((qb) => {
|
// new Brackets((qb) => {
|
||||||
qb.where(
|
// qb.where(
|
||||||
new Brackets((subAQb) => {
|
// new Brackets((subAQb) => {
|
||||||
subAQb.where('friendship.senderUsername = :username', {username : username})
|
// subAQb.where('friendship.senderUsername = :username', {username : username})
|
||||||
.andWhere('friendship.receiverUsername = :friendUsername', {friendUsername : friendUsername})
|
// .andWhere('friendship.receiverUsername = :friendUsername', {friendUsername : friendUsername})
|
||||||
})
|
// })
|
||||||
)
|
// )
|
||||||
.orWhere(
|
// .orWhere(
|
||||||
new Brackets((subBQb) => {
|
// new Brackets((subBQb) => {
|
||||||
subBQb.where('friendship.senderUsername = :friendUsername', {friendUsername : friendUsername})
|
// subBQb.where('friendship.senderUsername = :friendUsername', {friendUsername : friendUsername})
|
||||||
.andWhere('friendship.receiverUsername = :username', {username : username})
|
// .andWhere('friendship.receiverUsername = :username', {username : username})
|
||||||
})
|
// })
|
||||||
)
|
// )
|
||||||
}),
|
// }),
|
||||||
)
|
// )
|
||||||
.andWhere(
|
// .andWhere(
|
||||||
new Brackets((qb2) => {
|
// new Brackets((qb2) => {
|
||||||
// qb2.where('friendship.status = :status', {status : FriendshipStatus.ACCEPTED})
|
// // qb2.where('friendship.status = :status', {status : FriendshipStatus.ACCEPTED})
|
||||||
// .orWhere('friendship.status = :status', {status : FriendshipStatus.REQUESTED})
|
// // .orWhere('friendship.status = :status', {status : FriendshipStatus.REQUESTED})
|
||||||
qb2.where('friendship.status = :status', {status : FriendshipStatus.REQUESTED})
|
// qb2.where('friendship.status = :status', {status : FriendshipStatus.REQUESTED})
|
||||||
}),
|
// }),
|
||||||
)
|
// )
|
||||||
.getOne()
|
// .getOne()
|
||||||
}
|
// }
|
||||||
|
|
||||||
// console.log('END Find one friend by username: ')
|
// console.log('END Find one friend by username: ')
|
||||||
// console.log({...friendship})
|
// console.log({...friendship})
|
||||||
@@ -299,8 +299,8 @@ VS ------------------------------------------------
|
|||||||
// const relation = await this.friendshipRepository.findOneBy({where: {id: +relationshipId }, relations: ['sender', 'receiver']});
|
// const relation = await this.friendshipRepository.findOneBy({where: {id: +relationshipId }, relations: ['sender', 'receiver']});
|
||||||
// const relation = await this.friendshipRepository.findOne({where: {id: +relationshipId }, relations: ['sender', 'receiver']});
|
// const relation = await this.friendshipRepository.findOne({where: {id: +relationshipId }, relations: ['sender', 'receiver']});
|
||||||
|
|
||||||
// console.log('.service accept friendship')
|
console.log('.service accept friendship')
|
||||||
// console.log({...relation})
|
console.log({...relation})
|
||||||
if (!relation[0])
|
if (!relation[0])
|
||||||
throw new HttpException(`The requested relationship not found.`, HttpStatus.NOT_FOUND);
|
throw new HttpException(`The requested relationship not found.`, HttpStatus.NOT_FOUND);
|
||||||
// console.log(relation.sender)
|
// console.log(relation.sender)
|
||||||
|
|||||||
Reference in New Issue
Block a user