UNPKG

@vreden/meta

Version:

Baileys is a lightweight JavaScript library for interacting with the WhatsApp Web API using WebSocket.

1,117 lines (1,041 loc) 7.18 MB
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ "use strict"; var $protobuf = require("protobufjs/minimal"); // Common aliases var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); $root.HistorySync = (function() { /** * Namespace HistorySync. * @exports HistorySync * @namespace */ var HistorySync = {}; HistorySync.NotificationSettings = (function() { /** * Properties of a NotificationSettings. * @memberof HistorySync * @interface INotificationSettings * @property {string|null} [messageVibrate] NotificationSettings messageVibrate * @property {string|null} [messagePopup] NotificationSettings messagePopup * @property {string|null} [messageLight] NotificationSettings messageLight * @property {boolean|null} [lowPriorityNotifications] NotificationSettings lowPriorityNotifications * @property {boolean|null} [reactionsMuted] NotificationSettings reactionsMuted * @property {string|null} [callVibrate] NotificationSettings callVibrate */ /** * Constructs a new NotificationSettings. * @memberof HistorySync * @classdesc Represents a NotificationSettings. * @implements INotificationSettings * @constructor * @param {HistorySync.INotificationSettings=} [properties] Properties to set */ function NotificationSettings(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * NotificationSettings messageVibrate. * @member {string} messageVibrate * @memberof HistorySync.NotificationSettings * @instance */ NotificationSettings.prototype.messageVibrate = ""; /** * NotificationSettings messagePopup. * @member {string} messagePopup * @memberof HistorySync.NotificationSettings * @instance */ NotificationSettings.prototype.messagePopup = ""; /** * NotificationSettings messageLight. * @member {string} messageLight * @memberof HistorySync.NotificationSettings * @instance */ NotificationSettings.prototype.messageLight = ""; /** * NotificationSettings lowPriorityNotifications. * @member {boolean} lowPriorityNotifications * @memberof HistorySync.NotificationSettings * @instance */ NotificationSettings.prototype.lowPriorityNotifications = false; /** * NotificationSettings reactionsMuted. * @member {boolean} reactionsMuted * @memberof HistorySync.NotificationSettings * @instance */ NotificationSettings.prototype.reactionsMuted = false; /** * NotificationSettings callVibrate. * @member {string} callVibrate * @memberof HistorySync.NotificationSettings * @instance */ NotificationSettings.prototype.callVibrate = ""; /** * Creates a new NotificationSettings instance using the specified properties. * @function create * @memberof HistorySync.NotificationSettings * @static * @param {HistorySync.INotificationSettings=} [properties] Properties to set * @returns {HistorySync.NotificationSettings} NotificationSettings instance */ NotificationSettings.create = function create(properties) { return new NotificationSettings(properties); }; /** * Encodes the specified NotificationSettings message. Does not implicitly {@link HistorySync.NotificationSettings.verify|verify} messages. * @function encode * @memberof HistorySync.NotificationSettings * @static * @param {HistorySync.INotificationSettings} message NotificationSettings message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ NotificationSettings.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.messageVibrate != null && Object.hasOwnProperty.call(message, "messageVibrate")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.messageVibrate); if (message.messagePopup != null && Object.hasOwnProperty.call(message, "messagePopup")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.messagePopup); if (message.messageLight != null && Object.hasOwnProperty.call(message, "messageLight")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.messageLight); if (message.lowPriorityNotifications != null && Object.hasOwnProperty.call(message, "lowPriorityNotifications")) writer.uint32(/* id 4, wireType 0 =*/32).bool(message.lowPriorityNotifications); if (message.reactionsMuted != null && Object.hasOwnProperty.call(message, "reactionsMuted")) writer.uint32(/* id 5, wireType 0 =*/40).bool(message.reactionsMuted); if (message.callVibrate != null && Object.hasOwnProperty.call(message, "callVibrate")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.callVibrate); return writer; }; /** * Encodes the specified NotificationSettings message, length delimited. Does not implicitly {@link HistorySync.NotificationSettings.verify|verify} messages. * @function encodeDelimited * @memberof HistorySync.NotificationSettings * @static * @param {HistorySync.INotificationSettings} message NotificationSettings message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ NotificationSettings.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a NotificationSettings message from the specified reader or buffer. * @function decode * @memberof HistorySync.NotificationSettings * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {HistorySync.NotificationSettings} NotificationSettings * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ NotificationSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.HistorySync.NotificationSettings(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.messageVibrate = reader.string(); break; } case 2: { message.messagePopup = reader.string(); break; } case 3: { message.messageLight = reader.string(); break; } case 4: { message.lowPriorityNotifications = reader.bool(); break; } case 5: { message.reactionsMuted = reader.bool(); break; } case 6: { message.callVibrate = reader.string(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a NotificationSettings message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof HistorySync.NotificationSettings * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {HistorySync.NotificationSettings} NotificationSettings * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ NotificationSettings.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a NotificationSettings message. * @function verify * @memberof HistorySync.NotificationSettings * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ NotificationSettings.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.messageVibrate != null && message.hasOwnProperty("messageVibrate")) if (!$util.isString(message.messageVibrate)) return "messageVibrate: string expected"; if (message.messagePopup != null && message.hasOwnProperty("messagePopup")) if (!$util.isString(message.messagePopup)) return "messagePopup: string expected"; if (message.messageLight != null && message.hasOwnProperty("messageLight")) if (!$util.isString(message.messageLight)) return "messageLight: string expected"; if (message.lowPriorityNotifications != null && message.hasOwnProperty("lowPriorityNotifications")) if (typeof message.lowPriorityNotifications !== "boolean") return "lowPriorityNotifications: boolean expected"; if (message.reactionsMuted != null && message.hasOwnProperty("reactionsMuted")) if (typeof message.reactionsMuted !== "boolean") return "reactionsMuted: boolean expected"; if (message.callVibrate != null && message.hasOwnProperty("callVibrate")) if (!$util.isString(message.callVibrate)) return "callVibrate: string expected"; return null; }; /** * Creates a NotificationSettings message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof HistorySync.NotificationSettings * @static * @param {Object.<string,*>} object Plain object * @returns {HistorySync.NotificationSettings} NotificationSettings */ NotificationSettings.fromObject = function fromObject(object) { if (object instanceof $root.HistorySync.NotificationSettings) return object; var message = new $root.HistorySync.NotificationSettings(); if (object.messageVibrate != null) message.messageVibrate = String(object.messageVibrate); if (object.messagePopup != null) message.messagePopup = String(object.messagePopup); if (object.messageLight != null) message.messageLight = String(object.messageLight); if (object.lowPriorityNotifications != null) message.lowPriorityNotifications = Boolean(object.lowPriorityNotifications); if (object.reactionsMuted != null) message.reactionsMuted = Boolean(object.reactionsMuted); if (object.callVibrate != null) message.callVibrate = String(object.callVibrate); return message; }; /** * Creates a plain object from a NotificationSettings message. Also converts values to other types if specified. * @function toObject * @memberof HistorySync.NotificationSettings * @static * @param {HistorySync.NotificationSettings} message NotificationSettings * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ NotificationSettings.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.messageVibrate = ""; object.messagePopup = ""; object.messageLight = ""; object.lowPriorityNotifications = false; object.reactionsMuted = false; object.callVibrate = ""; } if (message.messageVibrate != null && message.hasOwnProperty("messageVibrate")) object.messageVibrate = message.messageVibrate; if (message.messagePopup != null && message.hasOwnProperty("messagePopup")) object.messagePopup = message.messagePopup; if (message.messageLight != null && message.hasOwnProperty("messageLight")) object.messageLight = message.messageLight; if (message.lowPriorityNotifications != null && message.hasOwnProperty("lowPriorityNotifications")) object.lowPriorityNotifications = message.lowPriorityNotifications; if (message.reactionsMuted != null && message.hasOwnProperty("reactionsMuted")) object.reactionsMuted = message.reactionsMuted; if (message.callVibrate != null && message.hasOwnProperty("callVibrate")) object.callVibrate = message.callVibrate; return object; }; /** * Converts this NotificationSettings to JSON. * @function toJSON * @memberof HistorySync.NotificationSettings * @instance * @returns {Object.<string,*>} JSON object */ NotificationSettings.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for NotificationSettings * @function getTypeUrl * @memberof HistorySync.NotificationSettings * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ NotificationSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/HistorySync.NotificationSettings"; }; return NotificationSettings; })(); HistorySync.AvatarUserSettings = (function() { /** * Properties of an AvatarUserSettings. * @memberof HistorySync * @interface IAvatarUserSettings * @property {string|null} [fbid] AvatarUserSettings fbid * @property {string|null} [password] AvatarUserSettings password */ /** * Constructs a new AvatarUserSettings. * @memberof HistorySync * @classdesc Represents an AvatarUserSettings. * @implements IAvatarUserSettings * @constructor * @param {HistorySync.IAvatarUserSettings=} [properties] Properties to set */ function AvatarUserSettings(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * AvatarUserSettings fbid. * @member {string} fbid * @memberof HistorySync.AvatarUserSettings * @instance */ AvatarUserSettings.prototype.fbid = ""; /** * AvatarUserSettings password. * @member {string} password * @memberof HistorySync.AvatarUserSettings * @instance */ AvatarUserSettings.prototype.password = ""; /** * Creates a new AvatarUserSettings instance using the specified properties. * @function create * @memberof HistorySync.AvatarUserSettings * @static * @param {HistorySync.IAvatarUserSettings=} [properties] Properties to set * @returns {HistorySync.AvatarUserSettings} AvatarUserSettings instance */ AvatarUserSettings.create = function create(properties) { return new AvatarUserSettings(properties); }; /** * Encodes the specified AvatarUserSettings message. Does not implicitly {@link HistorySync.AvatarUserSettings.verify|verify} messages. * @function encode * @memberof HistorySync.AvatarUserSettings * @static * @param {HistorySync.IAvatarUserSettings} message AvatarUserSettings message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AvatarUserSettings.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.fbid != null && Object.hasOwnProperty.call(message, "fbid")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.fbid); if (message.password != null && Object.hasOwnProperty.call(message, "password")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.password); return writer; }; /** * Encodes the specified AvatarUserSettings message, length delimited. Does not implicitly {@link HistorySync.AvatarUserSettings.verify|verify} messages. * @function encodeDelimited * @memberof HistorySync.AvatarUserSettings * @static * @param {HistorySync.IAvatarUserSettings} message AvatarUserSettings message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AvatarUserSettings.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an AvatarUserSettings message from the specified reader or buffer. * @function decode * @memberof HistorySync.AvatarUserSettings * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {HistorySync.AvatarUserSettings} AvatarUserSettings * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AvatarUserSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.HistorySync.AvatarUserSettings(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.fbid = reader.string(); break; } case 2: { message.password = reader.string(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an AvatarUserSettings message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof HistorySync.AvatarUserSettings * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {HistorySync.AvatarUserSettings} AvatarUserSettings * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AvatarUserSettings.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an AvatarUserSettings message. * @function verify * @memberof HistorySync.AvatarUserSettings * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ AvatarUserSettings.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.fbid != null && message.hasOwnProperty("fbid")) if (!$util.isString(message.fbid)) return "fbid: string expected"; if (message.password != null && message.hasOwnProperty("password")) if (!$util.isString(message.password)) return "password: string expected"; return null; }; /** * Creates an AvatarUserSettings message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof HistorySync.AvatarUserSettings * @static * @param {Object.<string,*>} object Plain object * @returns {HistorySync.AvatarUserSettings} AvatarUserSettings */ AvatarUserSettings.fromObject = function fromObject(object) { if (object instanceof $root.HistorySync.AvatarUserSettings) return object; var message = new $root.HistorySync.AvatarUserSettings(); if (object.fbid != null) message.fbid = String(object.fbid); if (object.password != null) message.password = String(object.password); return message; }; /** * Creates a plain object from an AvatarUserSettings message. Also converts values to other types if specified. * @function toObject * @memberof HistorySync.AvatarUserSettings * @static * @param {HistorySync.AvatarUserSettings} message AvatarUserSettings * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ AvatarUserSettings.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.fbid = ""; object.password = ""; } if (message.fbid != null && message.hasOwnProperty("fbid")) object.fbid = message.fbid; if (message.password != null && message.hasOwnProperty("password")) object.password = message.password; return object; }; /** * Converts this AvatarUserSettings to JSON. * @function toJSON * @memberof HistorySync.AvatarUserSettings * @instance * @returns {Object.<string,*>} JSON object */ AvatarUserSettings.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for AvatarUserSettings * @function getTypeUrl * @memberof HistorySync.AvatarUserSettings * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ AvatarUserSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/HistorySync.AvatarUserSettings"; }; return AvatarUserSettings; })(); HistorySync.PastParticipant = (function() { /** * Properties of a PastParticipant. * @memberof HistorySync * @interface IPastParticipant * @property {string|null} [userJid] PastParticipant userJid * @property {HistorySync.PastParticipant.LeaveReason|null} [leaveReason] PastParticipant leaveReason * @property {number|Long|null} [leaveTs] PastParticipant leaveTs */ /** * Constructs a new PastParticipant. * @memberof HistorySync * @classdesc Represents a PastParticipant. * @implements IPastParticipant * @constructor * @param {HistorySync.IPastParticipant=} [properties] Properties to set */ function PastParticipant(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * PastParticipant userJid. * @member {string} userJid * @memberof HistorySync.PastParticipant * @instance */ PastParticipant.prototype.userJid = ""; /** * PastParticipant leaveReason. * @member {HistorySync.PastParticipant.LeaveReason} leaveReason * @memberof HistorySync.PastParticipant * @instance */ PastParticipant.prototype.leaveReason = 0; /** * PastParticipant leaveTs. * @member {number|Long} leaveTs * @memberof HistorySync.PastParticipant * @instance */ PastParticipant.prototype.leaveTs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; /** * Creates a new PastParticipant instance using the specified properties. * @function create * @memberof HistorySync.PastParticipant * @static * @param {HistorySync.IPastParticipant=} [properties] Properties to set * @returns {HistorySync.PastParticipant} PastParticipant instance */ PastParticipant.create = function create(properties) { return new PastParticipant(properties); }; /** * Encodes the specified PastParticipant message. Does not implicitly {@link HistorySync.PastParticipant.verify|verify} messages. * @function encode * @memberof HistorySync.PastParticipant * @static * @param {HistorySync.IPastParticipant} message PastParticipant message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ PastParticipant.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.userJid != null && Object.hasOwnProperty.call(message, "userJid")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.userJid); if (message.leaveReason != null && Object.hasOwnProperty.call(message, "leaveReason")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.leaveReason); if (message.leaveTs != null && Object.hasOwnProperty.call(message, "leaveTs")) writer.uint32(/* id 3, wireType 0 =*/24).uint64(message.leaveTs); return writer; }; /** * Encodes the specified PastParticipant message, length delimited. Does not implicitly {@link HistorySync.PastParticipant.verify|verify} messages. * @function encodeDelimited * @memberof HistorySync.PastParticipant * @static * @param {HistorySync.IPastParticipant} message PastParticipant message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ PastParticipant.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a PastParticipant message from the specified reader or buffer. * @function decode * @memberof HistorySync.PastParticipant * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {HistorySync.PastParticipant} PastParticipant * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ PastParticipant.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.HistorySync.PastParticipant(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.userJid = reader.string(); break; } case 2: { message.leaveReason = reader.int32(); break; } case 3: { message.leaveTs = reader.uint64(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a PastParticipant message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof HistorySync.PastParticipant * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {HistorySync.PastParticipant} PastParticipant * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ PastParticipant.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a PastParticipant message. * @function verify * @memberof HistorySync.PastParticipant * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ PastParticipant.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.userJid != null && message.hasOwnProperty("userJid")) if (!$util.isString(message.userJid)) return "userJid: string expected"; if (message.leaveReason != null && message.hasOwnProperty("leaveReason")) switch (message.leaveReason) { default: return "leaveReason: enum value expected"; case 0: case 1: break; } if (message.leaveTs != null && message.hasOwnProperty("leaveTs")) if (!$util.isInteger(message.leaveTs) && !(message.leaveTs && $util.isInteger(message.leaveTs.low) && $util.isInteger(message.leaveTs.high))) return "leaveTs: integer|Long expected"; return null; }; /** * Creates a PastParticipant message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof HistorySync.PastParticipant * @static * @param {Object.<string,*>} object Plain object * @returns {HistorySync.PastParticipant} PastParticipant */ PastParticipant.fromObject = function fromObject(object) { if (object instanceof $root.HistorySync.PastParticipant) return object; var message = new $root.HistorySync.PastParticipant(); if (object.userJid != null) message.userJid = String(object.userJid); switch (object.leaveReason) { default: if (typeof object.leaveReason === "number") { message.leaveReason = object.leaveReason; break; } break; case "LEFT": case 0: message.leaveReason = 0; break; case "REMOVED": case 1: message.leaveReason = 1; break; } if (object.leaveTs != null) if ($util.Long) (message.leaveTs = $util.Long.fromValue(object.leaveTs)).unsigned = true; else if (typeof object.leaveTs === "string") message.leaveTs = parseInt(object.leaveTs, 10); else if (typeof object.leaveTs === "number") message.leaveTs = object.leaveTs; else if (typeof object.leaveTs === "object") message.leaveTs = new $util.LongBits(object.leaveTs.low >>> 0, object.leaveTs.high >>> 0).toNumber(true); return message; }; /** * Creates a plain object from a PastParticipant message. Also converts values to other types if specified. * @function toObject * @memberof HistorySync.PastParticipant * @static * @param {HistorySync.PastParticipant} message PastParticipant * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ PastParticipant.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.userJid = ""; object.leaveReason = options.enums === String ? "LEFT" : 0; if ($util.Long) { var long = new $util.Long(0, 0, true); object.leaveTs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.leaveTs = options.longs === String ? "0" : 0; } if (message.userJid != null && message.hasOwnProperty("userJid")) object.userJid = message.userJid; if (message.leaveReason != null && message.hasOwnProperty("leaveReason")) object.leaveReason = options.enums === String ? $root.HistorySync.PastParticipant.LeaveReason[message.leaveReason] === undefined ? message.leaveReason : $root.HistorySync.PastParticipant.LeaveReason[message.leaveReason] : message.leaveReason; if (message.leaveTs != null && message.hasOwnProperty("leaveTs")) if (typeof message.leaveTs === "number") object.leaveTs = options.longs === String ? String(message.leaveTs) : message.leaveTs; else object.leaveTs = options.longs === String ? $util.Long.prototype.toString.call(message.leaveTs) : options.longs === Number ? new $util.LongBits(message.leaveTs.low >>> 0, message.leaveTs.high >>> 0).toNumber(true) : message.leaveTs; return object; }; /** * Converts this PastParticipant to JSON. * @function toJSON * @memberof HistorySync.PastParticipant * @instance * @returns {Object.<string,*>} JSON object */ PastParticipant.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for PastParticipant * @function getTypeUrl * @memberof HistorySync.PastParticipant * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ PastParticipant.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/HistorySync.PastParticipant"; }; /** * LeaveReason enum. * @name HistorySync.PastParticipant.LeaveReason * @enum {number} * @property {number} LEFT=0 LEFT value * @property {number} REMOVED=1 REMOVED value */ PastParticipant.LeaveReason = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "LEFT"] = 0; values[valuesById[1] = "REMOVED"] = 1; return values; })(); return PastParticipant; })(); HistorySync.PastParticipants = (function() { /** * Properties of a PastParticipants. * @memberof HistorySync * @interface IPastParticipants * @property {string|null} [groupJid] PastParticipants groupJid * @property {Array.<HistorySync.IPastParticipant>|null} [pastParticipants] PastParticipants pastParticipants */ /** * Constructs a new PastParticipants. * @memberof HistorySync * @classdesc Represents a PastParticipants. * @implements IPastParticipants * @constructor * @param {HistorySync.IPastParticipants=} [properties] Properties to set */ function PastParticipants(properties) { this.pastParticipants = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } /** * PastParticipants groupJid. * @member {string} groupJid * @memberof HistorySync.PastParticipants * @instance */ PastParticipants.prototype.groupJid = ""; /** * PastParticipants pastParticipants. * @member {Array.<HistorySync.IPastParticipant>} pastParticipants * @memberof HistorySync.PastParticipants * @instance */ PastParticipants.prototype.pastParticipants = $util.emptyArray; /** * Creates a new PastParticipants instance using the specified properties. * @function create * @memberof HistorySync.PastParticipants * @static * @param {HistorySync.IPastParticipants=} [properties] Properties to set * @returns {HistorySync.PastParticipants} PastParticipants instance */ PastParticipants.create = function create(properties) { return new PastParticipants(properties); }; /** * Encodes the specified PastParticipants message. Does not implicitly {@link HistorySync.PastParticipants.verify|verify} messages. * @function encode * @memberof HistorySync.PastParticipants * @static * @param {HistorySync.IPastParticipants} message PastParticipants message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ PastParticipants.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.groupJid != null && Object.hasOwnProperty.call(message, "groupJid")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.groupJid); if (message.pastParticipants != null && message.pastParticipants.length) for (var i = 0; i < message.pastParticipants.length; ++i) $root.HistorySync.PastParticipant.encode(message.pastParticipants[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; /** * Encodes the specified PastParticipants message, length delimited. Does not implicitly {@link HistorySync.PastParticipants.verify|verify} messages. * @function encodeDelimited * @memberof HistorySync.PastParticipants * @static * @param {HistorySync.IPastParticipants} message PastParticipants message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ PastParticipants.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a PastParticipants message from the specified reader or buffer. * @function decode * @memberof HistorySync.PastParticipants * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {HistorySync.PastParticipants} PastParticipants * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ PastParticipants.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.HistorySync.PastParticipants(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.groupJid = reader.string(); break; } case 2: { if (!(message.pastParticipants && message.pastParticipants.length)) message.pastParticipants = []; message.pastParticipants.push($root.HistorySync.PastParticipant.decode(reader, reader.uint32())); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a PastParticipants message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof HistorySync.PastParticipants * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {HistorySync.PastParticipants} PastParticipants * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ PastParticipants.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a PastParticipants message. * @function verify * @memberof HistorySync.PastParticipants * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ PastParticipants.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.groupJid != null && message.hasOwnProperty("groupJid")) if (!$util.isString(message.groupJid)) return "groupJid: string expected"; if (message.pastParticipants != null && message.hasOwnProperty("pastParticipants")) { if (!Array.isArray(message.pastParticipants)) return "pastParticipants: array expected"; for (var i = 0; i < message.pastParticipants.length; ++i) { var error = $root.HistorySync.PastParticipant.verify(message.pastParticipants[i]); if (error) return "pastParticipants." + error; } } return null; }; /** * Creates a PastParticipants message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof HistorySync.PastParticipants * @static * @param {Object.<string,*>} object Plain object * @returns {HistorySync.PastParticipants} PastParticipants */ PastParticipants.fromObject = function fromObject(object) { if (object instanceof $root.HistorySync.PastParticipants) return object; var message = new $root.HistorySync.PastParticipants(); if (object.groupJid != null) message.groupJid = String(object.groupJid); if (object.pastParticipants) { if (!Array.isArray(object.pastParticipants)) throw TypeError(".HistorySync.PastParticipants.pastParticipants: array expected"); message.pastParticipants = []; for (var i = 0; i < object.pastParticipants.length; ++i) { if (typeof object.pastParticipants[i] !== "object") throw TypeError(".HistorySync.PastParticipants.pastParticipants: object expected"); message.pastParticipants[i] = $root.HistorySync.PastParticipant.fromObject(object.pastParticipants[i]); } } return message; }; /** * Creates a plain object from a PastParticipants message. Also converts values to other types if specified. * @function toObject * @memberof HistorySync.PastParticipants * @static * @param {HistorySync.PastParticipants} message PastParticipants * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ PastParticipants.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.arrays || options.defaults) object.pastParticipants = []; if (options.defaults) object.groupJid = ""; if (message.groupJid != null && message.hasOwnProperty("groupJid")) object.groupJid = message.groupJid; if (message.pastParticipants && message.pastParticipants.length) { object.pastParticipants = []; for (var j = 0; j < message.pastParticipants.length; ++j) object.pastParticipants[j] = $root.HistorySync.PastParticipant.toObject(message.pastParticipants[j], options); } return object; }; /** * Converts this PastParticipants to JSON. * @function toJSON * @memberof HistorySync.PastParticipants * @instance * @returns {Object.<string,*>} JSON object */ PastParticipants.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for PastParticipants * @function getTypeUrl * @memberof HistorySync.PastParticipants * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ PastParticipants.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/HistorySync.PastParticipants"; };