From a996f3bd05fc480247fd112f23fa3e67f7d5d7b5 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 7 Dec 2024 15:54:39 -0500 Subject: Added support for liking blog posts via webmention --- app/models/concerns/votable.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/models/concerns') 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 save! end end + + def like!(url, name) + return false unless votes.where(liker_url: url).empty? + + votes.create(liker_url: url, liker_name: name, upvote: 1).save + self.upvotes += 1 + save! + end end end -- cgit 1.4.1