about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-06-28 21:36:50 +0200
committerThibaut Girka <thib@sitedethib.com>2019-06-28 21:36:50 +0200
commit3922b518f79cd3098db19c392d5d10084839c200 (patch)
treeedef2c9d647e420aff33024a267d1d96cd721795 /lib
parentf7c0e326ab11a597b17a22dd8889f0690d7ffd73 (diff)
parent4f5b221be21e62257c16e47e998cdf757991f871 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/emoji_cli.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/mastodon/emoji_cli.rb b/lib/mastodon/emoji_cli.rb
index 97a822e45..beac1b1fd 100644
--- a/lib/mastodon/emoji_cli.rb
+++ b/lib/mastodon/emoji_cli.rb
@@ -15,6 +15,7 @@ module Mastodon
     option :suffix
     option :overwrite, type: :boolean
     option :unlisted, type: :boolean
+    option :category
     desc 'import PATH', 'Import emoji from a TAR GZIP archive at PATH'
     long_desc <<-LONG_DESC
       Imports custom emoji from a TAR GZIP archive specified by PATH.
@@ -22,6 +23,9 @@ module Mastodon
       Existing emoji will be skipped unless the --overwrite option
       is provided, in which case they will be overwritten.
 
+      You can specifiy a --category under which the emojis will be
+      grouped together.
+
       With the --prefix option, a prefix can be added to all
       generated shortcodes. Likewise, the --suffix option controls
       the suffix of all shortcodes.
@@ -33,6 +37,7 @@ module Mastodon
       imported = 0
       skipped  = 0
       failed   = 0
+      category = options[:category] ? CustomEmojiCategory.find_or_create_by(name: options[:category]) : nil
 
       Gem::Package::TarReader.new(Zlib::GzipReader.open(path)) do |tar|
         tar.each do |entry|
@@ -50,6 +55,7 @@ module Mastodon
           custom_emoji.image = StringIO.new(entry.read)
           custom_emoji.image_file_name = File.basename(entry.full_name)
           custom_emoji.visible_in_picker = !options[:unlisted]
+          custom_emoji.category = category
 
           if custom_emoji.save
             imported += 1