mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 04:02:54 -06:00
fix: Adjusts in settings with options always_online, read_messages and read_status
This commit is contained in:
parent
183efd427a
commit
a12231a0aa
@ -1,3 +1,9 @@
|
|||||||
|
# 1.4.3 (homolog)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Adjusts in settings with options always_online, read_messages and read_status
|
||||||
|
|
||||||
# 1.4.2 (2023-07-24 20:52)
|
# 1.4.2 (2023-07-24 20:52)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -455,7 +455,7 @@ export const readMessageSchema: JSONSchema7 = {
|
|||||||
$id: v4(),
|
$id: v4(),
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
readMessages: {
|
read_messages: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
minItems: 1,
|
minItems: 1,
|
||||||
uniqueItems: true,
|
uniqueItems: true,
|
||||||
@ -470,7 +470,7 @@ export const readMessageSchema: JSONSchema7 = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
required: ['readMessages'],
|
required: ['read_messages'],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const privacySettingsSchema: JSONSchema7 = {
|
export const privacySettingsSchema: JSONSchema7 = {
|
||||||
@ -884,7 +884,22 @@ export const settingsSchema: JSONSchema7 = {
|
|||||||
reject_call: { type: 'boolean', enum: [true, false] },
|
reject_call: { type: 'boolean', enum: [true, false] },
|
||||||
msg_call: { type: 'string' },
|
msg_call: { type: 'string' },
|
||||||
groups_ignore: { type: 'boolean', enum: [true, false] },
|
groups_ignore: { type: 'boolean', enum: [true, false] },
|
||||||
|
always_online: { type: 'boolean', enum: [true, false] },
|
||||||
|
read_messages: { type: 'boolean', enum: [true, false] },
|
||||||
|
read_status: { type: 'boolean', enum: [true, false] },
|
||||||
},
|
},
|
||||||
required: ['reject_call'],
|
required: [
|
||||||
...isNotEmpty('reject_call'),
|
'reject_call',
|
||||||
|
'groups_ignore',
|
||||||
|
'always_online',
|
||||||
|
'read_messages',
|
||||||
|
'read_status',
|
||||||
|
],
|
||||||
|
...isNotEmpty(
|
||||||
|
'reject_call',
|
||||||
|
'groups_ignore',
|
||||||
|
'always_online',
|
||||||
|
'read_messages',
|
||||||
|
'read_status',
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,7 @@ class Key {
|
|||||||
remoteJid: string;
|
remoteJid: string;
|
||||||
}
|
}
|
||||||
export class ReadMessageDto {
|
export class ReadMessageDto {
|
||||||
readMessages: Key[];
|
read_messages: Key[];
|
||||||
}
|
}
|
||||||
|
|
||||||
class LastMessage {
|
class LastMessage {
|
||||||
|
@ -2,4 +2,7 @@ export class SettingsDto {
|
|||||||
reject_call?: boolean;
|
reject_call?: boolean;
|
||||||
msg_call?: string;
|
msg_call?: string;
|
||||||
groups_ignore?: boolean;
|
groups_ignore?: boolean;
|
||||||
|
always_online?: boolean;
|
||||||
|
read_messages?: boolean;
|
||||||
|
read_status?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ export class SettingsRaw {
|
|||||||
reject_call?: boolean;
|
reject_call?: boolean;
|
||||||
msg_call?: string;
|
msg_call?: string;
|
||||||
groups_ignore?: boolean;
|
groups_ignore?: boolean;
|
||||||
|
always_online?: boolean;
|
||||||
|
read_messages?: boolean;
|
||||||
|
read_status?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const settingsSchema = new Schema<SettingsRaw>({
|
const settingsSchema = new Schema<SettingsRaw>({
|
||||||
@ -13,6 +16,9 @@ const settingsSchema = new Schema<SettingsRaw>({
|
|||||||
reject_call: { type: Boolean, required: true },
|
reject_call: { type: Boolean, required: true },
|
||||||
msg_call: { type: String, required: true },
|
msg_call: { type: String, required: true },
|
||||||
groups_ignore: { type: Boolean, required: true },
|
groups_ignore: { type: Boolean, required: true },
|
||||||
|
always_online: { type: Boolean, required: true },
|
||||||
|
read_messages: { type: Boolean, required: true },
|
||||||
|
read_status: { type: Boolean, required: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const SettingsModel = dbserver?.model(
|
export const SettingsModel = dbserver?.model(
|
||||||
|
@ -362,6 +362,15 @@ export class WAStartupService {
|
|||||||
this.localSettings.groups_ignore = data?.groups_ignore;
|
this.localSettings.groups_ignore = data?.groups_ignore;
|
||||||
this.logger.verbose(`Settings groups_ignore: ${this.localSettings.groups_ignore}`);
|
this.logger.verbose(`Settings groups_ignore: ${this.localSettings.groups_ignore}`);
|
||||||
|
|
||||||
|
this.localSettings.always_online = data?.always_online;
|
||||||
|
this.logger.verbose(`Settings always_online: ${this.localSettings.always_online}`);
|
||||||
|
|
||||||
|
this.localSettings.read_messages = data?.read_messages;
|
||||||
|
this.logger.verbose(`Settings read_messages: ${this.localSettings.read_messages}`);
|
||||||
|
|
||||||
|
this.localSettings.read_status = data?.read_status;
|
||||||
|
this.logger.verbose(`Settings read_status: ${this.localSettings.read_status}`);
|
||||||
|
|
||||||
this.logger.verbose('Settings loaded');
|
this.logger.verbose('Settings loaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,8 +380,13 @@ export class WAStartupService {
|
|||||||
this.logger.verbose(`Settings reject_call: ${data.reject_call}`);
|
this.logger.verbose(`Settings reject_call: ${data.reject_call}`);
|
||||||
this.logger.verbose(`Settings msg_call: ${data.msg_call}`);
|
this.logger.verbose(`Settings msg_call: ${data.msg_call}`);
|
||||||
this.logger.verbose(`Settings groups_ignore: ${data.groups_ignore}`);
|
this.logger.verbose(`Settings groups_ignore: ${data.groups_ignore}`);
|
||||||
|
this.logger.verbose(`Settings always_online: ${data.always_online}`);
|
||||||
|
this.logger.verbose(`Settings read_messages: ${data.read_messages}`);
|
||||||
|
this.logger.verbose(`Settings read_status: ${data.read_status}`);
|
||||||
Object.assign(this.localSettings, data);
|
Object.assign(this.localSettings, data);
|
||||||
this.logger.verbose('Settings set');
|
this.logger.verbose('Settings set');
|
||||||
|
|
||||||
|
this.client?.ws?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async findSettings() {
|
public async findSettings() {
|
||||||
@ -387,6 +401,9 @@ export class WAStartupService {
|
|||||||
this.logger.verbose(`Settings url: ${data.reject_call}`);
|
this.logger.verbose(`Settings url: ${data.reject_call}`);
|
||||||
this.logger.verbose(`Settings msg_call: ${data.msg_call}`);
|
this.logger.verbose(`Settings msg_call: ${data.msg_call}`);
|
||||||
this.logger.verbose(`Settings groups_ignore: ${data.groups_ignore}`);
|
this.logger.verbose(`Settings groups_ignore: ${data.groups_ignore}`);
|
||||||
|
this.logger.verbose(`Settings always_online: ${data.always_online}`);
|
||||||
|
this.logger.verbose(`Settings read_messages: ${data.read_messages}`);
|
||||||
|
this.logger.verbose(`Settings read_status: ${data.read_status}`);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -847,6 +864,7 @@ export class WAStartupService {
|
|||||||
printQRInTerminal: false,
|
printQRInTerminal: false,
|
||||||
browser,
|
browser,
|
||||||
version,
|
version,
|
||||||
|
markOnlineOnConnect: this.localSettings.always_online,
|
||||||
connectTimeoutMs: 60_000,
|
connectTimeoutMs: 60_000,
|
||||||
qrTimeout: 40_000,
|
qrTimeout: 40_000,
|
||||||
defaultQueryTimeoutMs: undefined,
|
defaultQueryTimeoutMs: undefined,
|
||||||
@ -1143,6 +1161,14 @@ export class WAStartupService {
|
|||||||
source: getDevice(received.key.id),
|
source: getDevice(received.key.id),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.localSettings.read_messages && received.key.id !== 'status@broadcast') {
|
||||||
|
await this.client.readMessages([received.key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.localSettings.read_status && received.key.id === 'status@broadcast') {
|
||||||
|
await this.client.readMessages([received.key]);
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.log(messageRaw);
|
this.logger.log(messageRaw);
|
||||||
|
|
||||||
this.logger.verbose('Sending data to webhook in event MESSAGES_UPSERT');
|
this.logger.verbose('Sending data to webhook in event MESSAGES_UPSERT');
|
||||||
@ -2400,7 +2426,7 @@ export class WAStartupService {
|
|||||||
this.logger.verbose('Marking message as read');
|
this.logger.verbose('Marking message as read');
|
||||||
try {
|
try {
|
||||||
const keys: proto.IMessageKey[] = [];
|
const keys: proto.IMessageKey[] = [];
|
||||||
data.readMessages.forEach((read) => {
|
data.read_messages.forEach((read) => {
|
||||||
if (isJidGroup(read.remoteJid) || isJidUser(read.remoteJid)) {
|
if (isJidGroup(read.remoteJid) || isJidUser(read.remoteJid)) {
|
||||||
keys.push({
|
keys.push({
|
||||||
remoteJid: read.remoteJid,
|
remoteJid: read.remoteJid,
|
||||||
@ -2640,7 +2666,6 @@ export class WAStartupService {
|
|||||||
await this.client.updateGroupsAddPrivacy(settings.privacySettings.groupadd);
|
await this.client.updateGroupsAddPrivacy(settings.privacySettings.groupadd);
|
||||||
this.logger.verbose('Groups add privacy updated');
|
this.logger.verbose('Groups add privacy updated');
|
||||||
|
|
||||||
// reinicia a instancia
|
|
||||||
this.client?.ws?.close();
|
this.client?.ws?.close();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -61,6 +61,9 @@ export declare namespace wa {
|
|||||||
reject_call?: boolean;
|
reject_call?: boolean;
|
||||||
msg_call?: string;
|
msg_call?: string;
|
||||||
groups_ignore?: boolean;
|
groups_ignore?: boolean;
|
||||||
|
always_online?: boolean;
|
||||||
|
read_messages?: boolean;
|
||||||
|
read_status?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type StateConnection = {
|
export type StateConnection = {
|
||||||
|
Loading…
Reference in New Issue
Block a user