Skip to content

Commit f516486

Browse files
committed
refactor: improve code formatting and remove unused dependencies and constants
1 parent b378113 commit f516486

2 files changed

Lines changed: 23 additions & 32 deletions

File tree

api/src/services/colony/colony.service.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '../../repositories';
99
import { Place } from '../../types/models';
1010
import * as console from 'console';
11-
import {includes} from 'lodash';
11+
import { includes } from 'lodash';
1212

1313
/** Service for dealing with colony */
1414
@Service()
@@ -18,16 +18,16 @@ export class ColonyService {
1818
private roleAssignmentRepository: RoleAssignmentRepository,
1919
private roleRepository: RoleRepository,
2020
private memberRepository: MemberRepository,
21-
) {}
22-
21+
) { }
22+
2323
public async find(colonyId: number): Promise<Place> {
2424
return await this.colonyRepository.find(colonyId);
2525
}
2626

2727
public async getHoods(colonyId: number): Promise<any> {
2828
return await this.colonyRepository.getHoods(colonyId);
2929
}
30-
30+
3131
public async getAccessInfoByUsername(colonyId: number): Promise<object> {
3232
const deputyCode = await this.roleRepository.roleMap.ColonyDeputy;
3333
const ownerCode = await this.roleRepository.roleMap.ColonyLeader;
@@ -50,8 +50,8 @@ export class ColonyService {
5050
const ownerCode = await this.roleRepository.roleMap.ColonyLeader;
5151
let oldOwner = null;
5252
let newOwner = 0;
53-
const oldDeputies = [0,0,0,0,0,0,0,0];
54-
const newDeputies = [0,0,0,0,0,0,0,0];
53+
const oldDeputies = [0, 0, 0, 0, 0, 0, 0, 0];
54+
const newDeputies = [0, 0, 0, 0, 0, 0, 0, 0];
5555
const data = await this
5656
.roleAssignmentRepository
5757
.getAccessInfoByID(colonyId, ownerCode, deputyCode);
@@ -72,8 +72,8 @@ export class ColonyService {
7272
const response: any = await this.memberRepository.getPrimaryRoleName(oldOwner);
7373
if (response.length !== 0) {
7474
const primaryRoleId = response[0].primary_role_id;
75-
if (ownerCode === primaryRoleId){
76-
await this.memberRepository.update(oldOwner, {primary_role_id: null});
75+
if (ownerCode === primaryRoleId) {
76+
await this.memberRepository.update(oldOwner, { primary_role_id: null });
7777
}
7878
}
7979
}
@@ -84,8 +84,8 @@ export class ColonyService {
8484
const response: any = await this.memberRepository.getPrimaryRoleName(oldOwner);
8585
if (response.length !== 0) {
8686
const primaryRoleId = response[0].primary_role_id;
87-
if (ownerCode === primaryRoleId){
88-
await this.memberRepository.update(oldOwner, {primary_role_id: null});
87+
if (ownerCode === primaryRoleId) {
88+
await this.memberRepository.update(oldOwner, { primary_role_id: null });
8989
}
9090
}
9191
}
@@ -110,7 +110,7 @@ export class ColonyService {
110110
if (response.length !== 0) {
111111
const primaryRoleId = response[0].primary_role_id;
112112
if (primaryRoleId && deputyCode === primaryRoleId) {
113-
this.memberRepository.update(oldDeputies, {primary_role_id: null});
113+
this.memberRepository.update(oldDeputies, { primary_role_id: null });
114114
}
115115
}
116116
});
@@ -123,7 +123,7 @@ export class ColonyService {
123123
if (response.length !== 0) {
124124
const primaryRoleId = response[0].primary_role_id;
125125
if (deputyCode === primaryRoleId) {
126-
this.memberRepository.update(oldDeputies, {primary_role_id: null});
126+
this.memberRepository.update(oldDeputies, { primary_role_id: null });
127127
}
128128
}
129129
});
@@ -146,8 +146,6 @@ export class ColonyService {
146146
return (
147147
[
148148
this.roleRepository.roleMap.Admin,
149-
this.roleRepository.roleMap.CityMayor,
150-
this.roleRepository.roleMap.DeputyMayor,
151149
this.roleRepository.roleMap.ColonyRepresentative,
152150
].includes(assignment.role_id) ||
153151
([

api/src/services/inbox/inbox.service.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
import { Service } from 'typedi';
22

3-
import { InboxRepository, ColonyRepository } from '../../repositories';
3+
import { InboxRepository } from '../../repositories';
44
import sanitizeHtml from 'sanitize-html';
5-
import { stringify } from 'ts-jest';
6-
import {forEach} from 'lodash';
75

86
/** Service for dealing with messages on message boards */
97
@Service()
108
export class InboxService {
11-
public static readonly MAX_QUERY_LIMIT = 1000;
12-
public static readonly VALID_ORDERS = ['id', 'date'];
13-
public static readonly VALID_ORDER_DIRECTIONS = ['asc', 'desc'];
149

15-
constructor(private inboxRepository: InboxRepository) {}
10+
constructor(private inboxRepository: InboxRepository) { }
1611

1712
public async changeInboxIntro(placeId, Intro): Promise<any> {
1813
console.log(`Service${placeId}`);
1914
return await this.inboxRepository.changeInboxIntro(placeId, Intro);
2015
}
2116

22-
public async deleteInboxMessages(
23-
messageIds: number[],
24-
placeId: number,
25-
): Promise<any> {
26-
return this.inboxRepository.deleteInboxMessages(messageIds, placeId);
27-
}
17+
public async deleteInboxMessages(
18+
messageIds: number[],
19+
placeId: number,
20+
): Promise<any> {
21+
return this.inboxRepository.deleteInboxMessages(messageIds, placeId);
22+
}
2823

2924
public async getAdminInfo(placeId, memberId): Promise<any> {
3025
return await this.inboxRepository.getAdminInfo(placeId, memberId);
@@ -45,7 +40,7 @@ export class InboxService {
4540
): Promise<any> {
4641
return await this.inboxRepository.postInboxMessage(memberId, placeId, subject, message);
4742
}
48-
43+
4944
public async postInboxAllMessage(
5045
memberId: number,
5146
locations: number[],
@@ -80,8 +75,6 @@ export class InboxService {
8075
);
8176
}
8277

83-
84-
8578
public async sanitize(uncleanInfo: string): Promise<any> {
8679
const cleanInfo = sanitizeHtml(uncleanInfo, {
8780
allowedTags: [
@@ -167,8 +160,8 @@ export class InboxService {
167160
a: ['href', 'name', 'target'],
168161
img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'usemap'],
169162
font: ['color', 'size'],
170-
map: [ 'name' ],
171-
area: [ 'alt', 'title', 'href', 'coords', 'shape', 'target', 'class' ],
163+
map: ['name'],
164+
area: ['alt', 'title', 'href', 'coords', 'shape', 'target', 'class'],
172165
marquee: ['width', 'height', 'direction'],
173166
},
174167
});

0 commit comments

Comments
 (0)