]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/message.rb
Strengthen the tokens used in email reply addresses
[rails.git] / app / models / message.rb
index 49c11e900898923beb558d78d8d2b6e35845a158..0068bc3de504ee2d7e380cc2641b4ae1889082ba 100644 (file)
@@ -59,13 +59,10 @@ class Message < ApplicationRecord
     RichText.new(self[:body_format], self[:body])
   end
 
-  def digest
-    md5 = Digest::MD5.new
-    md5 << from_user_id.to_s
-    md5 << to_user_id.to_s
-    md5 << sent_on.xmlschema
-    md5 << title
-    md5 << body
-    md5.hexdigest
+  def notification_token
+    sha256 = Digest::SHA256.new
+    sha256 << Rails.application.key_generator.generate_key("openstreetmap/message")
+    sha256 << id.to_s
+    sha256.base64digest[0, 8]
   end
 end