403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  D:/laragon4/www/wa-gateway/server/dto/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/laragon4/www/wa-gateway/server/dto/list.js
const { ulid } = require("ulid");
const { prepareMediaMessage } = require("../lib/helper");
class Row {
  constructor(props) {
    Object.assign(this, props);
    if (!this.id) {
      this.id = ulid(Date.now());
    }
    if (!this.header) {
      this.header = "";
    }
  }
}

class ListSection {
  constructor(props) {
    Object.assign(this, props);
    this.rows = props.rows.map((row) => new Row(row));
  }
}

class Section {
  constructor(props) {
    Object.assign(this, props);
    this.list = props.list.map((item) => new ListSection(item));
  }

  toSectionsString() {
    return JSON.stringify({
      title: this.buttonText,
      sections: this.list,
    });
  }
}
const formatListMsg = async (sections, footer, message,sock, image) => {


  const generate = await (async () => {
    if (image) {
      return await prepareMediaMessage(sock, {
        mediatype: "image",
        media: image,
      });
    }
  })();

  return {
    viewOnceMessage: {
      message: {
        messageContextInfo: {
          deviceListMetadata: {},
          deviceListMetadataVersion: 2,
        },
        interactiveMessage: {
          body: {
            text: (function () {
              return message;
            })(),
          },
          footer: {
            text: footer ?? "..",
          },
          header: (function () {
            if (generate?.message?.imageMessage) {
              return {
                hasMediaAttachment: !!generate.message.imageMessage,
                imageMessage: generate.message.imageMessage,
              };
            }
          })(),
          nativeFlowMessage: {
            buttons: sections.map(function (value) {
              return {
                name: "single_select",
                buttonParamsJson: value.toSectionsString(),
              };
            }),
            messageParamsJson: JSON.stringify({
              from: "api",
              templateId: ulid(Date.now()),
            }),
          },
        },
      },
    },
  };
};

module.exports = { formatListMsg, Section };

Youez - 2016 - github.com/yon3zu
LinuXploit