sn-revisions 0.2.5 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edbf1ef739e32f8ac0d20f3c717193b28465d11c219284061d5305b6a6b0dfd1
4
- data.tar.gz: af6623b32de817b40d83806e1ae286a1481fe039e276b907147c9b03712971ce
3
+ metadata.gz: fdc634d650b631459df49d982f3c7ea51228c692e04ba4224bbb3be97516aa41
4
+ data.tar.gz: bf01b99bf6fb788a9b307f57f7694ff60e2f505d49951013422cd1756765f246
5
5
  SHA512:
6
- metadata.gz: a4864c8780a6f346c2638b9d05ba4cb599873db0fc0e7e7778f1ceee7663fffc31c3e8095246578d60c10825ca93d5519b01b358c22a7d7146416e8db22ab767
7
- data.tar.gz: 25db854727398ffe4275e8fb2be3b09beebd75618a5fb63442b5448226d5a8964733aacf540794b3c099336fdd3f712b1f09169f3794589bc0878103956c2ff2
6
+ metadata.gz: 1e6222b6a9443a3488bfac3a70c633fbb04f58a59c9bf451f3689c4d40aa14be242456e0b1debc704fb35af84de98c1eb2f768173a1015a46e55bd4c4a77bfa6
7
+ data.tar.gz: 9731a1d4a62effa3a304ce7bcae50847f130083fb95ded7e014027a97c1f09767d8a58d97c50b04f60cc2db5ae93ef441c7115774bae0204817b1948a922c48b
@@ -7,7 +7,7 @@ module Revisions
7
7
 
8
8
  def authenticate_user
9
9
  user = Revisions::User.find(params[:uid])
10
- if user.key != params[:key]
10
+ if !ActiveSupport::SecurityUtils.secure_compare(user.key, params[:key])
11
11
  render_unauthorized
12
12
  return
13
13
  end
@@ -39,7 +39,12 @@ module Revisions
39
39
  end
40
40
  end
41
41
 
42
- render :json => {:name => "Note History", :supported_types => [:Note], :actions => actions}
42
+ render :json => {
43
+ :name => "Note History",
44
+ :supported_types => [:Note],
45
+ :actions => actions,
46
+ deprecation: 'This extension will soon be replaced by Remote History, accessible via the History menu.'
47
+ }
43
48
  end
44
49
 
45
50
  end
@@ -1,4 +1,4 @@
1
- require_dependency "revisions/application_controller"
1
+ require_dependency 'revisions/application_controller'
2
2
 
3
3
  module Revisions
4
4
  class ItemsController < ApplicationController
@@ -7,11 +7,19 @@ module Revisions
7
7
  auth_params = params[:auth_params]
8
8
 
9
9
  items.each do |item_hash|
10
- item = current_user.items.find_or_create_by(:item_uuid => item_hash["uuid"])
10
+ item = current_user.items.find_or_create_by(item_uuid: item_hash['uuid'])
11
11
  item.prune_history
12
- item.add_revision(item_hash["content"], item_hash["enc_item_key"], item_hash["auth_hash"], auth_params)
13
- if item.content_type == nil
14
- item.content_type = item_hash["content_type"]
12
+
13
+ item.add_revision(
14
+ items_key_id: item_hash['items_key_id'],
15
+ duplicate_of: item_hash['duplicate_of'],
16
+ content: item_hash['content'],
17
+ enc_item_key: item_hash['enc_item_key'],
18
+ auth_hash: item_hash['auth_hash'],
19
+ auth_params: auth_params
20
+ )
21
+ if item.content_type.nil?
22
+ item.content_type = item_hash['content_type']
15
23
  item.save
16
24
  end
17
25
  end
@@ -3,13 +3,21 @@ module Revisions
3
3
 
4
4
  has_many :revisions, -> { order 'created_at desc' }
5
5
 
6
- def add_revision(content, item_key, auth_hash, auth_params)
6
+ def add_revision(
7
+ items_key_id: nil,
8
+ duplicate_of: nil,
9
+ content: nil,
10
+ enc_item_key: nil,
11
+ auth_hash: nil,
12
+ auth_params: nil
13
+ )
7
14
  revision = self.revisions.new
15
+ revision.items_key_id = items_key_id
16
+ revision.duplicate_of = duplicate_of
8
17
  revision.content = content
9
- revision.enc_item_key = item_key
18
+ revision.enc_item_key = enc_item_key
10
19
  revision.auth_hash = auth_hash
11
20
  revision.auth_params = auth_params.to_json
12
- # revision.num = self.revisions.length > 0 && self.revisions.first.num ? (self.revisions.first.num + 1) : 0
13
21
  revision.save
14
22
  end
15
23
 
@@ -1,6 +1,5 @@
1
1
  module Revisions
2
2
  class User < ApplicationRecord
3
3
  has_many :items
4
-
5
4
  end
6
5
  end
@@ -0,0 +1,6 @@
1
+ class AddItemsKeyId < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :revisions_revisions, :duplicate_of, :string, after: :id
4
+ add_column :revisions_revisions, :items_key_id, :string, after: :duplicate_of
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Revisions
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sn-revisions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Standard Notes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -75,6 +75,7 @@ files:
75
75
  - db/migrate/20170211001350_create_revisions_users.rb
76
76
  - db/migrate/20170713154559_change_item_key_to_text.rb
77
77
  - db/migrate/20180526182951_add_auth_params_to_revisions.rb
78
+ - db/migrate/20200925151406_add_items_key_id.rb
78
79
  - lib/revisions.rb
79
80
  - lib/revisions/engine.rb
80
81
  - lib/revisions/version.rb
@@ -83,7 +84,7 @@ homepage: https://standardnotes.org
83
84
  licenses:
84
85
  - MIT
85
86
  metadata: {}
86
- post_install_message:
87
+ post_install_message:
87
88
  rdoc_options: []
88
89
  require_paths:
89
90
  - lib
@@ -98,8 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  - !ruby/object:Gem::Version
99
100
  version: '0'
100
101
  requirements: []
101
- rubygems_version: 3.0.3
102
- signing_key:
102
+ rubygems_version: 3.0.6
103
+ signing_key:
103
104
  specification_version: 4
104
105
  summary: The Note History extension for Standard Notes allows you to track changes
105
106
  to your notes, and restore them to previous versions.