Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Criar opção para não sincronizar os status postados pelos contatos do celular #981

Open
dandrade-pedbot opened this issue Mar 16, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@dandrade-pedbot
Copy link

Is your feature request related to a problem? Please describe.
Uma das maiores causas de instabilidades e alto consumo de memória ram pela biblioteca, está na sincronização de status postados pelos clientes.
Mensagens trocadas em conversas, utilizam pouca memória ram, pois é apenas texto, já os status são todos vídeos, portanto, um celular que possua por exemplo 5000 contatos salvos, recebe uma avalanche de status assim que conecta, jogando os recursos de memória ram lá em cima e por consequência trazendo instabilidade para biblioteca.

Describe the solution you'd like
Seria interessante adicionar uma opção na inicialização do client, para escolher se deseja ou não sincronizar os status.

Caso não deseje sincronizar os status, é necessário realizar as seguintes supressões:

  • Assim que conecta o chip, não deve puxar os status na sincronização inicial;
  • Quando o chip já está conectado, não deve receber os novos status que os contatos estão postando;
  • É importante manter a sincronização dos status que são postados pelo aparelho conectado, pois caso algum contato responda esse status, e ele não estiver sincronizado na biblioteca, não vai ser possível realizar a vinculação que a mensagem recebida é a resposta de um status.

Describe alternatives you've considered
Necessário seguir os critérios informados acima.

Additional context
Já consegui realizar uma parte disso, que é a supressão da sincronização inicial dos status, segue abaixo as alterações para isso:

wa-js/src/whatsapp/functions/handleHistorySyncNotification.ts

/*!
 * Copyright 2021 WPPConnect Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { exportModule } from '../exportModule';

export interface HistorySyncNotification {
  syncType: Number
}

export interface HistoryData {
  historySyncNotification: HistorySyncNotification
}

/** @whatsapp 889877
 * @whatsapp 889877 >= 2.2222.8
 */
export declare function handleHistorySyncNotification(args: HistoryData): Promise<any>;

exportModule(
  exports,
  {
    handleHistorySyncNotification: 'handleHistorySyncNotification',
  },
  (m) => m.handleHistorySyncNotification
);

wa-js/src/chat/events/handleStatusNotifications.ts:

/*!
 * Copyright 2021 WPPConnect Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as webpack from '../../webpack';
import { wrapModuleFunction } from '../../whatsapp/exportModule';
import { handleHistorySyncNotification } from '../../whatsapp/functions';

webpack.onInjected(() => register());

function register() {
  wrapModuleFunction(handleHistorySyncNotification, (func, ...args) => {
    const [data] = args;
    const dataString = JSON.stringify(data);
    const parsedData = JSON.parse(dataString);
    if (parsedData.historySyncNotification.syncType === 1) {
      return new Promise(() => {
        return;
      });
    }

    return func(...args);
  });
}
@dandrade-pedbot dandrade-pedbot added enhancement New feature or request needs triage labels Mar 16, 2023
@Saifallak
Copy link
Contributor

I guess fixed by 845bcf6 and 6bf2e68

@edgardmessias
Copy link
Contributor

Thanks @Saifallak , I did only the inicial syncronization, I need to work with new stories after sync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants