@vielhuber/wahelper 1.7.5 → 1.7.6

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.
Files changed (3) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
  3. package/wahelper.js +12 -3
package/README.md CHANGED
@@ -57,7 +57,8 @@ npx wahelper \
57
57
  --action "fetch_messages" \
58
58
  --filter '{"from":"491234567890","to":"491234567890","message":"meeting","date_from":"2026-01-01","date_until":"2026-12-31"}' \
59
59
  --limit 42 \
60
- --order "desc"
60
+ --order "desc" \
61
+ --exclude-body
61
62
 
62
63
  # view a single message by id
63
64
  --action "view_message" \
@@ -95,7 +96,8 @@ $wahelper->fetchMessages(
95
96
  'date_until' => '2026-12-31'
96
97
  ],
97
98
  limit: 42,
98
- order: 'desc'
99
+ order: 'desc',
100
+ exclude_body: true
99
101
  );
100
102
 
101
103
  // view a single message by id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vielhuber/wahelper",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "Lightweight whatsapp integration layer.",
5
5
  "main": "wahelper.js",
6
6
  "files": [
package/wahelper.js CHANGED
@@ -123,7 +123,14 @@ export default class wahelper {
123
123
  } else if (this.args.filter && typeof this.args.filter === 'object') {
124
124
  filter = this.args.filter;
125
125
  }
126
- response = await this.fetchMessages(filter, this.args.limit, this.args.order);
126
+ response = await this.fetchMessages(
127
+ filter,
128
+ this.args.limit,
129
+ this.args.order,
130
+ this.args.exclude_body === true ||
131
+ this.args.exclude_body === 'true' ||
132
+ this.args.exclude_body === '1'
133
+ );
127
134
  }
128
135
  if (this.args.action === 'view_message') {
129
136
  response = await this.viewMessage(this.args.id);
@@ -145,7 +152,7 @@ export default class wahelper {
145
152
  this.log('cli stop');
146
153
  }
147
154
 
148
- async fetchMessages(filter = null, limit = null, order = null) {
155
+ async fetchMessages(filter = null, limit = null, order = null, excludeBody = false) {
149
156
  // fetch directly from database — no connection to daemon needed
150
157
  try {
151
158
  let where = [];
@@ -173,8 +180,10 @@ export default class wahelper {
173
180
  }
174
181
  }
175
182
  let orderDir = order === 'asc' ? 'ASC' : 'DESC';
183
+ let columns =
184
+ 'id, `from`, `to`, ' + (!excludeBody ? 'content, ' : '') + 'media_filename, timestamp, `read`';
176
185
  let sql =
177
- 'SELECT id, `from`, `to`, content, media_filename, timestamp, `read` FROM messages' +
186
+ 'SELECT ' + columns + ' FROM messages' +
178
187
  (where.length > 0 ? ' WHERE ' + where.join(' AND ') : '') +
179
188
  ' ORDER BY timestamp ' + orderDir +
180
189
  (limit !== null ? ' LIMIT ' + parseInt(limit, 10) : '');