|
|
@@ -2,8 +2,10 @@ import { Inject, Service } from '@tsed/di';
|
|
|
import axios from 'axios';
|
|
|
import { addHours } from 'date-fns';
|
|
|
|
|
|
-import { Relation } from '~/entities/relation';
|
|
|
+// import { Relation } from '~/entities/relation';
|
|
|
+import { RelationMock } from '~/entities/relation-mock';
|
|
|
import { RelationRepository } from '~/repositories/relation';
|
|
|
+import { RelationMockRepository } from '~/repositories/relation-mock';
|
|
|
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
@@ -15,7 +17,9 @@ export class RelationsService {
|
|
|
@Inject()
|
|
|
relationRepository: RelationRepository;
|
|
|
|
|
|
- async getSupportedGrowiCommands(relation:Relation):Promise<any> {
|
|
|
+ relationMockRepository: RelationMockRepository;
|
|
|
+
|
|
|
+ async getSupportedGrowiCommands(relation:RelationMock):Promise<any> {
|
|
|
// generate API URL
|
|
|
const url = new URL('/_api/v3/slack-integration/supported-commands', relation.growiUri);
|
|
|
return axios.get(url.toString(), {
|
|
|
@@ -25,7 +29,7 @@ export class RelationsService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- async syncSupportedGrowiCommands(relation:Relation): Promise<Relation> {
|
|
|
+ async syncSupportedGrowiCommands(relation:RelationMock): Promise<RelationMock> {
|
|
|
const res = await this.getSupportedGrowiCommands(relation);
|
|
|
const { supportedCommandsForBroadcastUse, supportedCommandsForSingleUse } = res.data;
|
|
|
relation.supportedCommandsForBroadcastUse = supportedCommandsForBroadcastUse;
|
|
|
@@ -35,7 +39,7 @@ export class RelationsService {
|
|
|
return this.relationRepository.save(relation);
|
|
|
}
|
|
|
|
|
|
- async syncRelation(relation:Relation, baseDate:Date):Promise<Relation|null> {
|
|
|
+ async syncRelation(relation:RelationMock, baseDate:Date):Promise<RelationMock|null> {
|
|
|
const distanceMillisecondsToExpiredAt = relation.getDistanceInMillisecondsToExpiredAt(baseDate);
|
|
|
|
|
|
if (distanceMillisecondsToExpiredAt < 0) {
|
|
|
@@ -61,7 +65,7 @@ export class RelationsService {
|
|
|
return relation;
|
|
|
}
|
|
|
|
|
|
- async isSupportedGrowiCommandForSingleUse(relation:Relation, growiCommandType:string, baseDate:Date):Promise<boolean> {
|
|
|
+ async isSupportedGrowiCommandForSingleUse(relation:RelationMock, growiCommandType:string, baseDate:Date):Promise<boolean> {
|
|
|
const syncedRelation = await this.syncRelation(relation, baseDate);
|
|
|
if (syncedRelation == null) {
|
|
|
return false;
|
|
|
@@ -69,7 +73,7 @@ export class RelationsService {
|
|
|
return relation.supportedCommandsForSingleUse.includes(growiCommandType);
|
|
|
}
|
|
|
|
|
|
- async isSupportedGrowiCommandForBroadcastUse(relation:Relation, growiCommandType:string, baseDate:Date):Promise<boolean> {
|
|
|
+ async isSupportedGrowiCommandForBroadcastUse(relation:RelationMock, growiCommandType:string, baseDate:Date):Promise<boolean> {
|
|
|
const syncedRelation = await this.syncRelation(relation, baseDate);
|
|
|
if (syncedRelation == null) {
|
|
|
return false;
|