|
|
@ -14,8 +14,8 @@ import {NoActionSpecifiedError} from "./errors/NoActionSpecifiedError";
|
|
|
|
import {UserNotFoundError} from "./errors/UserNotFoundError";
|
|
|
|
import {UserNotFoundError} from "./errors/UserNotFoundError";
|
|
|
|
import globals from "./globals";
|
|
|
|
import globals from "./globals";
|
|
|
|
import {InternalEvents} from "./InternalEvents";
|
|
|
|
import {InternalEvents} from "./InternalEvents";
|
|
|
|
import {Activity} from "./models";
|
|
|
|
|
|
|
|
import * as models from "./models";
|
|
|
|
import * as models from "./models";
|
|
|
|
|
|
|
|
import {Activity} from "./models";
|
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable:completed-docs
|
|
|
|
// tslint:disable:completed-docs
|
|
|
|
|
|
|
|
|
|
|
@ -263,8 +263,10 @@ namespace dataaccess {
|
|
|
|
export async function createRequest(sender: number, receiver: number, requestType?: RequestType) {
|
|
|
|
export async function createRequest(sender: number, receiver: number, requestType?: RequestType) {
|
|
|
|
requestType = requestType || RequestType.FRIENDREQUEST;
|
|
|
|
requestType = requestType || RequestType.FRIENDREQUEST;
|
|
|
|
|
|
|
|
|
|
|
|
const requestExists = !!await models.Request.findOne({where:
|
|
|
|
const requestExists = !!await models.Request.findOne({
|
|
|
|
{senderId: sender, receiverId: receiver, requestType}});
|
|
|
|
where:
|
|
|
|
|
|
|
|
{senderId: sender, receiverId: receiver, requestType},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!requestExists) {
|
|
|
|
if (!requestExists) {
|
|
|
|
const request = await models.Request.create({senderId: sender, receiverId: receiver, requestType});
|
|
|
|
const request = await models.Request.create({senderId: sender, receiverId: receiver, requestType});
|
|
|
|