sn-revisions 0.2.3 → 0.2.8

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
- SHA1:
3
- metadata.gz: 061ce6ce9a3ae3e37de60f220e739ac6f2adcc70
4
- data.tar.gz: d71ad4784401dd7ca3271986e449a2dd2b1c5420
2
+ SHA256:
3
+ metadata.gz: 73c57395a3f4ea1fc8bac76dfd665fe9c93f86a46b7ac335e218f989b0307628
4
+ data.tar.gz: cde2ad068f9c7524bfc13253df6a73bdbd898d36e24abd9a2347dfd094e6874b
5
5
  SHA512:
6
- metadata.gz: 5cc0418eea127ea49c7b072fcc121eb37a2f84d9e1b8fd7378b1b9f7939e79e593a2d56f31163454cd121c655f4bf0dfb75772962f2a88063f2dbe1e05489c1c
7
- data.tar.gz: ddc078ec863473a696559068e5867f0cf898ba93fe2889eafbffc5b9a002a20aac7780b9742347f1b05b8a82962e0c54decbb0bb35e8077c29841e22c96574ab
6
+ metadata.gz: 2ae879dc7ac4ee69c35ace6773a97735d6aa05c99f15bda47b98724d03d266230c3614d53edb428dab117308b06c51b9428585255d180ad3c66a238dd180abbb
7
+ data.tar.gz: c748f941e3393cd5535b17e5c57ecc506e2eb2b4d8393b6f606d650c680393ba69e698318419386bd85de19c5231a44b78f546cf49c5bff725ecf6b835b2d14a
@@ -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,22 +1,44 @@
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]
8
+ directive = params[:directive]
9
+
10
+ if directive == 'delete-account'
11
+ current_user.destroy
12
+ head :no_content
13
+ return
14
+ end
9
15
 
10
16
  items.each do |item_hash|
11
- item = current_user.items.find_or_create_by(:item_uuid => item_hash["uuid"])
17
+ item = current_user.items.find_or_create_by(item_uuid: item_hash['uuid'])
18
+
19
+ if item_hash['deleted'] == true
20
+ item.destroy
21
+ head :no_content
22
+ next
23
+ end
24
+
12
25
  item.prune_history
13
- item.add_revision(item_hash["content"], item_hash["enc_item_key"], item_hash["auth_hash"], auth_params)
14
- if item.content_type == nil
15
- item.content_type = item_hash["content_type"]
26
+
27
+ item.add_revision(
28
+ items_key_id: item_hash['items_key_id'],
29
+ duplicate_of: item_hash['duplicate_of'],
30
+ content: item_hash['content'],
31
+ enc_item_key: item_hash['enc_item_key'],
32
+ auth_hash: item_hash['auth_hash'],
33
+ auth_params: auth_params
34
+ )
35
+ if item.content_type.nil?
36
+ item.content_type = item_hash['content_type']
16
37
  item.save
17
38
  end
18
39
  end
19
- end
20
40
 
41
+ head :no_content
42
+ end
21
43
  end
22
44
  end
@@ -11,7 +11,7 @@ module Revisions
11
11
  end
12
12
 
13
13
  if revision.auth_params
14
- # stupid issue where I forgot to serialize auth params before inserting it into MILLIONS of rows
14
+ # Handles issue where auth params were not previously properly serialized before being inserted
15
15
  begin
16
16
  auth_params = JSON.parse(revision.auth_params)
17
17
  rescue
@@ -1,15 +1,23 @@
1
1
  module Revisions
2
2
  class Item < ApplicationRecord
3
3
 
4
- has_many :revisions, -> { order 'created_at desc' }
5
-
6
- def add_revision(content, item_key, auth_hash, auth_params)
4
+ has_many :revisions, -> { order 'created_at desc' }, dependent: :destroy
5
+
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
- has_many :items
4
-
3
+ has_many :items, dependent: :destroy
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.3'
2
+ VERSION = '0.2.8'
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.3
4
+ version: 0.2.8
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: 2018-05-27 00:00:00.000000000 Z
11
+ date: 2020-12-14 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
@@ -77,7 +84,7 @@ homepage: https://standardnotes.org
77
84
  licenses:
78
85
  - MIT
79
86
  metadata: {}
80
- post_install_message:
87
+ post_install_message:
81
88
  rdoc_options: []
82
89
  require_paths:
83
90
  - lib
@@ -92,9 +99,8 @@ 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
97
- signing_key:
102
+ rubygems_version: 3.0.6
103
+ signing_key:
98
104
  specification_version: 4
99
105
  summary: The Note History extension for Standard Notes allows you to track changes
100
106
  to your notes, and restore them to previous versions.