UNPKG

@warriorteam/zalo-personal

Version:

Unofficial Zalo Personal API for JavaScript - A powerful library for interacting with Zalo personal accounts with URL attachment support

41 lines (40 loc) 1.36 kB
import { ZaloApiError } from "../Errors/ZaloApiError.js"; import { apiFactory } from "../utils.js"; export const editNoteGroupFactory = apiFactory()((api, ctx, utils) => { const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/topic/updatev2`); /** * Edit an existing note in a group * * @param options Options for editing the note * @param groupId Group ID to create note from * * @throws ZaloApiError */ return async function editNoteGroup(options, groupId) { const params = { grid: groupId, type: 0, color: -16777216, emoji: "", startTime: -1, duration: -1, params: JSON.stringify({ title: options.title, }), topicId: options.topicId, repeat: 0, imei: ctx.imei, pinAct: options.pinAct ? 1 : 2, }; const encryptedParams = utils.encodeAES(JSON.stringify(params)); if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); const response = await utils.request(serviceURL, { method: "POST", body: new URLSearchParams({ params: encryptedParams, }), }); return utils.resolve(response); }; });