diff --git a/Gemfile b/Gemfile
index cbf0a9a9b858b..3b3ba445d0742 100644
--- a/Gemfile
+++ b/Gemfile
@@ -102,6 +102,7 @@ gem "uglifier", "~> 4.2" # Uglifier minifies JavaScript files
gem "ulid", "~> 1.2" # Universally Unique Lexicographically Sortable Identifier implementation for Ruby
gem "validate_url", "~> 1.0" # Library for validating urls in Rails
gem "webpacker", "~> 3.5" # Use webpack to manage app-like JavaScript modules in Rails
+gem "opengraph_parser" #Using opengraph_parser to parse metadata from websites.
group :development do
gem "better_errors", "~> 2.6" # Provides a better error page for Rails and other Rack apps
diff --git a/Gemfile.lock b/Gemfile.lock
index 2ec15b6efd5a6..2ff284242c9ae 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -512,6 +512,9 @@ GEM
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
+ opengraph_parser (0.2.3)
+ addressable
+ nokogiri
orm_adapter (0.5.0)
os (1.0.1)
parallel (1.19.1)
@@ -921,6 +924,7 @@ DEPENDENCIES
omniauth (~> 1.9)
omniauth-github (~> 1.3)
omniauth-twitter (~> 1.4)
+ opengraph_parser
parallel_tests (~> 2.31)
pg (~> 1.2)
pry (~> 0.12)
@@ -994,4 +998,4 @@ RUBY VERSION
ruby 2.6.5p114
BUNDLED WITH
- 2.0.2
+ 2.1.4
diff --git a/app/models/message.rb b/app/models/message.rb
index 4aeb6f1f9014a..44cc4158602d2 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -93,13 +93,23 @@ def append_rich_links(html)
doc = Nokogiri::HTML(html)
doc.css("a").each do |anchor|
if (article = rich_link_article(anchor))
- html += "
- #{"" if article.main_image.present?}
- #{article.title}
-
#{article.cached_user.name}・#{article.readable_publish_date || 'Draft Post'}
- ".html_safe
+ if article.class == Hash
+ html += "
+ #{"" if article[:image].present?}
+ #{article[:title]}
+ #{article[:description]}
+ ".html_safe
+ else
+ html += "
+ #{"" if article.main_image.present?}
+ #{article.title}
+
#{article.cached_user.name}・#{article.readable_publish_date || 'Draft Post'}
+ ".html_safe
+ end
elsif (tag = rich_link_tag(anchor))
html += "