Skip to content

Commit ed5ff08

Browse files
Merge pull request #17 from EvolutionAPI/v2.0.0
V2.0.0
2 parents a578425 + 256bd3e commit ed5ff08

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,10 @@ AUTHENTICATION_API_KEY=429683C4C977415CAAFCCE10F7D57E11
213213
# If you leave this option as true, the instances will be exposed in the fetch instances endpoint.
214214
AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=true
215215
LANGUAGE=en
216+
217+
# Define a global proxy to be used if the instance does not have one
218+
# PROXY_HOST=
219+
# PROXY_PORT=80
220+
# PROXY_PROTOCOL=http
221+
# PROXY_USERNAME=
222+
# PROXY_PASSWORD=

src/api/services/cache.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class CacheService {
2121
}
2222

2323
public async hGet(key: string, field: string) {
24+
if (!this.cache) {
25+
return null;
26+
}
2427
try {
2528
const data = await this.cache.hGet(key, field);
2629

@@ -43,6 +46,9 @@ export class CacheService {
4346
}
4447

4548
public async hSet(key: string, field: string, value: any) {
49+
if (!this.cache) {
50+
return;
51+
}
4652
try {
4753
const json = JSON.stringify(value, BufferJSON.replacer);
4854

@@ -67,6 +73,9 @@ export class CacheService {
6773
}
6874

6975
async hDelete(key: string, field: string) {
76+
if (!this.cache) {
77+
return false;
78+
}
7079
try {
7180
await this.cache.hDelete(key, field);
7281
return true;

src/api/services/channel.service.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,31 @@ export class ChannelStartupService {
338338
}
339339

340340
public async loadProxy() {
341+
this.localProxy.enabled = false;
342+
343+
if (process.env.PROXY_HOST) {
344+
this.localProxy.enabled = true;
345+
this.localProxy.host = process.env.PROXY_HOST;
346+
this.localProxy.port = process.env.PROXY_PORT || '80';
347+
this.localProxy.protocol = process.env.PROXY_PROTOCOL || 'http';
348+
this.localProxy.username = process.env.PROXY_USERNAME;
349+
this.localProxy.password = process.env.PROXY_PASSWORD;
350+
}
351+
341352
const data = await this.prismaRepository.proxy.findUnique({
342353
where: {
343354
instanceId: this.instanceId,
344355
},
345356
});
346357

347-
this.localProxy.enabled = data?.enabled;
348-
this.localProxy.host = data?.host;
349-
this.localProxy.port = data?.port;
350-
this.localProxy.protocol = data?.protocol;
351-
this.localProxy.username = data?.username;
352-
this.localProxy.password = data?.password;
358+
if (data?.enabled) {
359+
this.localProxy.enabled = true;
360+
this.localProxy.host = data?.host;
361+
this.localProxy.port = data?.port;
362+
this.localProxy.protocol = data?.protocol;
363+
this.localProxy.username = data?.username;
364+
this.localProxy.password = data?.password;
365+
}
353366
}
354367

355368
public async setProxy(data: ProxyDto) {

0 commit comments

Comments
 (0)