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