sn-revisions 0.2.2 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 54e2021f6695bc323ffbc7b370f88f8117fb538a
4
- data.tar.gz: 41e8ed79ab6ede9130584e5f6cc92b1cc5d2b20a
2
+ SHA256:
3
+ metadata.gz: e6fd8a7a570e4e2d838855b595302516522e9b210b40fac78da8ffe5cda37a6d
4
+ data.tar.gz: d65a449b84683914bf5d9a4dc6e20c38813b1f61df7a7cd7fcac06a98dae28ee
5
5
  SHA512:
6
- metadata.gz: 9e4909e8f01bb411aff628aabd09371c63f291474f8945fdbf378521eabc02d6e6aed367fc2c123f23cb32c853932364f5a8b9c40ce6679431a054ae5a363da5
7
- data.tar.gz: 7d7dfb7e2e9c41d3205db925f53b09558e31aec08feabb5a5b5cc4fb0a804cc337aa96b36a4213f1b9ff2f408b58a4188b5a54fb6ad9ab914da183277e3e0d07
6
+ metadata.gz: b01748ffda7142f8692d6d35ccb4f95b0583bf8643ac8a204199a46c64e98ce4aabe691752882455b5a18b3da032aefd29114c4f048c282791e433778924497a
7
+ data.tar.gz: a8eda9db60436e1a271e3f75c2b0920f89f69329f63f0eedff41073b6b15a493c346d2777658deaaaf68b067062590278717b6ebe3bee0192f9fc53c71890c18
@@ -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,33 +1,30 @@
1
- require_dependency "revisions/application_controller"
1
+ require_dependency 'revisions/application_controller'
2
2
 
3
3
  module Revisions
4
4
  class ItemsController < ApplicationController
5
-
6
5
  def save
7
6
  items = params[:items]
8
7
  auth_params = params[:auth_params]
9
8
 
10
- if items == nil || items.length == 0
11
- # auth params migration
12
- current_user.items.each do |item|
13
- item.revisions.each do |revision|
14
- revision.auth_params = auth_params
15
- revision.save
16
- end
17
- end
18
- return
19
- end
20
-
21
9
  items.each do |item_hash|
22
- 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'])
23
11
  item.prune_history
24
- item.add_revision(item_hash["content"], item_hash["enc_item_key"], item_hash["auth_hash"], auth_params)
25
- if item.content_type == nil
26
- 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']
27
23
  item.save
28
24
  end
29
25
  end
30
- end
31
26
 
27
+ head :no_content
28
+ end
32
29
  end
33
30
  end
@@ -10,7 +10,14 @@ module Revisions
10
10
  return
11
11
  end
12
12
 
13
- auth_params = revision.auth_params ? JSON.parse(revision.auth_params) : nil
13
+ if revision.auth_params
14
+ # Handles issue where auth params were not previously properly serialized before being inserted
15
+ begin
16
+ auth_params = JSON.parse(revision.auth_params)
17
+ rescue
18
+ auth_params = JSON.parse(revision.auth_params.gsub('=>', ':'))
19
+ end
20
+ end
14
21
 
15
22
  render :json => {
16
23
  :item => revision.as_json.merge({:uuid => revision.item.item_uuid, :content_type => revision.item.content_type}),
@@ -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
 
@@ -43,7 +51,9 @@ module Revisions
43
51
  end
44
52
  end
45
53
 
46
- Revision.destroy(discard_ids)
54
+ Revision
55
+ .where(id: discard_ids)
56
+ .delete_all
47
57
  end
48
58
  end
49
59
  end
@@ -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.2'
2
+ VERSION = '0.2.7'
3
3
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sn-revisions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Standard Notes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-26 00:00:00.000000000 Z
11
+ date: 2020-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 5.0.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 5.0.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
27
33
  description: The Note History extension for Standard Notes allows you to track changes
28
34
  to your notes, and restore them to previous versions.
29
35
  email:
@@ -69,6 +75,7 @@ files:
69
75
  - db/migrate/20170211001350_create_revisions_users.rb
70
76
  - db/migrate/20170713154559_change_item_key_to_text.rb
71
77
  - db/migrate/20180526182951_add_auth_params_to_revisions.rb
78
+ - db/migrate/20200925151406_add_items_key_id.rb
72
79
  - lib/revisions.rb
73
80
  - lib/revisions/engine.rb
74
81
  - lib/revisions/version.rb
@@ -92,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
99
  - !ruby/object:Gem::Version
93
100
  version: '0'
94
101
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.6.12
102
+ rubygems_version: 3.0.3
97
103
  signing_key:
98
104
  specification_version: 4
99
105
  summary: The Note History extension for Standard Notes allows you to track changes