calmlens 0.31.0 → 0.31.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45077d27cc23f4fbfbae7a056b96b6ce575a5d0ba2e306ff0d96daacb9406dd9
4
- data.tar.gz: 321e112bc8d3efab4dd12e9c32c7118335c5759442a2a20883677fbc77ee779a
3
+ metadata.gz: cb92c3f2338dd93756f4b08b425f6234d31a1f77c0000c938814d671474170ff
4
+ data.tar.gz: 4c57d18c2fa05e27b81171760e3878c0cd3476e0756d7aee5efcd29462aa6f65
5
5
  SHA512:
6
- metadata.gz: 3f9cb8b271474880af0d0e54853a935faac758ac167d38109cc16fb2910c3fc7a376217d3764b832991eab19d0c86a0c80a199baa48911ef5dc8791ba97bdc8a
7
- data.tar.gz: b7e71f082a6bbe59529f2c49bf46b0a02aae43316b2bf390801e4a791e72272dc31627d0289c4ad6f3550c396f6703aa22043a4b09a1d9e1e7178c80f50d647a
6
+ metadata.gz: c0864ec596bc1f6bef85fe947a7235db81bb728561975de69b662f163e7cffb22a101381bc04a7a268934203b2ff53e5a4d5958521a02c2e12cb0a6ceaaef023
7
+ data.tar.gz: be5a3d9d4237cd912d2adbae2210b8a2f2e394da7eefeabeca786d516f7e48d8487ec3763da79c7da0038fb61f9cf62351c655f65f71a81eb4d7bfca80fe8373
@@ -296,9 +296,9 @@ module CalmLens
296
296
  # the API key as its events' actor; the test hook's is a reviewer's (a `user`).
297
297
  def record_decision(item, decision, note, by_api_key)
298
298
  apply_outcome(item, decision, 'requested')
299
- # Like the API: the human review queue's decision settles its review, one through the API
300
- # leaves it waiting.
301
- item['classification']['moderation']['pendingReview'] = nil unless by_api_key
299
+ # Like the API: the human review queue's decision settles its review, and so does the app's own
300
+ # decision through the API.
301
+ item['classification']['moderation']['pendingReview'] = nil
302
302
  review = { 'id' => @create_id.call('rev'), 'decision' => decision, 'note' => note,
303
303
  'decidedBy' => deep_copy(API_KEY_ACTOR), 'reviewedAt' => @now.call, 'applied' => true }
304
304
  actor = by_api_key ? API_KEY_ACTOR : REVIEWER_ACTOR
@@ -328,7 +328,13 @@ module CalmLens
328
328
  fail!(ErrorCodes::ASSET_PROCESSING) if processing
329
329
  status = item['classification']['moderation']['decision']
330
330
  fail!(ErrorCodes::ASSET_DECISION_NOT_ALLOWED) if status.nil? && !%w[blocked purged].include?(decision)
331
- fail!(ErrorCodes::ASSET_DECISION_UNCHANGED) if status == decision
331
+ if status == decision
332
+ # Like the API: agreeing with the decision a queued review waits on settles the review,
333
+ # leaving the decision as it is.
334
+ fail!(ErrorCodes::ASSET_DECISION_UNCHANGED) if item['classification']['moderation']['pendingReview'].nil?
335
+ item['classification']['moderation']['pendingReview'] = nil
336
+ return item
337
+ end
332
338
  fail!(ErrorCodes::ASSET_CONTENT_PURGED) if status == 'purged' && decision != 'blocked'
333
339
 
334
340
  record_decision(item, decision, note, true)
@@ -1258,6 +1264,13 @@ module CalmLens
1258
1264
  # the most recent ones, newest first, while CONTEXT_USED_ITEMS posts and
1259
1265
  # CONTEXT_USED_CHARACTERS characters allow, returned oldest first. The newest is always kept.
1260
1266
  def select_context(items)
1267
+ # Like the API's schema, a reference that isn't an asset ID is refused before any lookup.
1268
+ Array(items).each_with_index do |item, index|
1269
+ asset_id = item.is_a?(Hash) ? item['assetId'] : nil
1270
+ next if asset_id.is_a?(String) && asset_id.match?(ASSET_ID_PATTERN)
1271
+
1272
+ invalid!('validation/invalid-format', "context.items.#{index}.assetId")
1273
+ end
1261
1274
  posts = Array(items).map do |item|
1262
1275
  asset_id = item.is_a?(Hash) ? item['assetId'] : nil
1263
1276
  asset = asset_id.is_a?(String) ? @state.assets[asset_id] : nil
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CalmLens
4
4
  # The gem version. The gemspec and the User-Agent header read it from here.
5
- VERSION = '0.31.0'
5
+ VERSION = '0.31.1'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calmlens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CalmLens