diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-07 15:54:39 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-07 15:54:39 -0500 |
commit | a996f3bd05fc480247fd112f23fa3e67f7d5d7b5 (patch) | |
tree | 2df0a56e8cc42ccd632db5b2c022b7dbf8d74444 /app/models | |
parent | 59f5508d5bc0cee856105a5bd52e1deaee44b842 (diff) | |
download | thoughts-a996f3bd05fc480247fd112f23fa3e67f7d5d7b5.tar.gz thoughts-a996f3bd05fc480247fd112f23fa3e67f7d5d7b5.tar.bz2 thoughts-a996f3bd05fc480247fd112f23fa3e67f7d5d7b5.zip |
Added support for liking blog posts via webmention
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/votable.rb | 8 | ||||
-rw-r--r-- | app/models/vote.rb | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/models/concerns/votable.rb b/app/models/concerns/votable.rb index ba6e6d5..40b3a2a 100644 --- a/app/models/concerns/votable.rb +++ b/app/models/concerns/votable.rb | |||
@@ -39,5 +39,13 @@ module Votable | |||
39 | save! | 39 | save! |
40 | end | 40 | end |
41 | end | 41 | end |
42 | |||
43 | def like!(url, name) | ||
44 | return false unless votes.where(liker_url: url).empty? | ||
45 | |||
46 | votes.create(liker_url: url, liker_name: name, upvote: 1).save | ||
47 | self.upvotes += 1 | ||
48 | save! | ||
49 | end | ||
42 | end | 50 | end |
43 | end | 51 | end |
diff --git a/app/models/vote.rb b/app/models/vote.rb index e2d8386..fced5bd 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb | |||
@@ -2,5 +2,4 @@ class Vote < ApplicationRecord | |||
2 | belongs_to :votable, polymorphic: true | 2 | belongs_to :votable, polymorphic: true |
3 | 3 | ||
4 | validates :upvote, presence: true, inclusion: { in: [0, 1] } | 4 | validates :upvote, presence: true, inclusion: { in: [0, 1] } |
5 | validates :ip, presence: true | ||
6 | end | 5 | end |