@apocaliss92/nodelink-js 0.4.30 → 0.4.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import {
3
3
  BaichuanRtspServer,
4
4
  ReolinkBaichuanApi,
5
5
  autoDetectDeviceType
6
- } from "../chunk-AZZKLRJV.js";
6
+ } from "../chunk-5Z7NVPV6.js";
7
7
  import "../chunk-AHY4L7JI.js";
8
8
  import {
9
9
  __require
package/dist/index.cjs CHANGED
@@ -19820,6 +19820,13 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19820
19820
  * Once closed, the API instance should not be reused.
19821
19821
  */
19822
19822
  _closed = false;
19823
+ /**
19824
+ * Off-handle for the auto-bridge between the global email-push bus
19825
+ * and this api's `simpleEventListeners`. Set in the constructor
19826
+ * when `emailPushCameraId` is provided; released in `close()`.
19827
+ * `undefined` means no bridge was requested for this api.
19828
+ */
19829
+ emailPushAutoBridgeOff;
19823
19830
  // ─────────────────────────────────────────────────────────────────────────────
19824
19831
  // SOCKET POOL - Tag-based socket management
19825
19832
  // ─────────────────────────────────────────────────────────────────────────────
@@ -21162,6 +21169,12 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
21162
21169
  this.rebootAfterConsecutiveEconnreset = Math.floor(econnresetThreshold);
21163
21170
  }
21164
21171
  this.setupGeneralClientListeners();
21172
+ if (opts.emailPushCameraId) {
21173
+ this.emailPushAutoBridgeOff = this.subscribeEmailPushEvents({
21174
+ cameraId: opts.emailPushCameraId,
21175
+ channel: opts.emailPushChannel ?? 0
21176
+ });
21177
+ }
21165
21178
  }
21166
21179
  /**
21167
21180
  * CGI forward: fetch RTSP URL for a channel via `GetRtspUrl`.
@@ -22285,6 +22298,13 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
22285
22298
  async close(options) {
22286
22299
  if (this._closed) return;
22287
22300
  this._closed = true;
22301
+ if (this.emailPushAutoBridgeOff) {
22302
+ try {
22303
+ this.emailPushAutoBridgeOff();
22304
+ } catch {
22305
+ }
22306
+ this.emailPushAutoBridgeOff = void 0;
22307
+ }
22288
22308
  if (this.sessionGuardIntervalTimer) {
22289
22309
  clearInterval(this.sessionGuardIntervalTimer);
22290
22310
  this.sessionGuardIntervalTimer = void 0;
@@ -41131,8 +41151,10 @@ function createEmailPushServer(params) {
41131
41151
  let server;
41132
41152
  let status = buildInitialStatus(config);
41133
41153
  function parseRecipient(rcpt) {
41134
- const [local, domain] = rcpt.toLowerCase().split("@");
41135
- if (!local || !domain) return void 0;
41154
+ const at = rcpt.lastIndexOf("@");
41155
+ if (at <= 0 || at === rcpt.length - 1) return void 0;
41156
+ const local = rcpt.slice(0, at);
41157
+ const domain = rcpt.slice(at + 1).toLowerCase();
41136
41158
  return { local, domain };
41137
41159
  }
41138
41160
  function resolveCameraIdFromRecipient(rcpt) {
@@ -41155,9 +41177,6 @@ function createEmailPushServer(params) {
41155
41177
  return;
41156
41178
  }
41157
41179
  const receivedAtMs = Date.now();
41158
- const imageAttachment = (parsed.attachments ?? []).find(
41159
- (a) => a && typeof a.contentType === "string" && a.contentType.toLowerCase().startsWith("image/") && Buffer.isBuffer(a.content)
41160
- );
41161
41180
  const event = {
41162
41181
  cameraId,
41163
41182
  recipient,
@@ -41165,18 +41184,11 @@ function createEmailPushServer(params) {
41165
41184
  receivedAtMs,
41166
41185
  subject: parsed.subject ?? "",
41167
41186
  from: typeof parsed.from === "object" && parsed.from !== null && "text" in parsed.from ? String(parsed.from.text) : "",
41168
- bodyExcerpt: (parsed.text ?? "").slice(0, 500),
41169
- ...imageAttachment ? {
41170
- attachment: {
41171
- contentType: imageAttachment.contentType,
41172
- data: imageAttachment.content,
41173
- ...imageAttachment.filename ? { filename: imageAttachment.filename } : {}
41174
- }
41175
- } : {}
41187
+ bodyExcerpt: (parsed.text ?? "").slice(0, 500)
41176
41188
  };
41177
41189
  status.messagesAccepted++;
41178
41190
  log.info(
41179
- `Email push for camera=${cameraId} type=${event.inferredType} attachment=${event.attachment ? `${event.attachment.contentType} ${event.attachment.data.length}B` : "none"} subject="${event.subject.slice(0, 80)}"`
41191
+ `Email push for camera=${cameraId} type=${event.inferredType} subject="${event.subject.slice(0, 80)}"`
41180
41192
  );
41181
41193
  emitEmailPushEvent(event);
41182
41194
  }