Skip to content

Commit

Permalink
Merge pull request #3719 from pooza/dev/4.32.0
Browse files Browse the repository at this point in the history
4.32.0
  • Loading branch information
pooza authored Jul 21, 2024
2 parents 11c4a3e + 2d1eb52 commit 681689d
Show file tree
Hide file tree
Showing 55 changed files with 123 additions and 1,026 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.3
ruby-version: 3.3.4
- name: apt install
run: |
sudo apt update
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.3
3.3.4
33 changes: 18 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ GIT

GIT
remote: https://github.com/pooza/ginseng-fediverse.git
revision: 13cf153752407c2c262b097d240599a5755a62e4
revision: 4e9e62529d2017093d0875595275aded7f83a478
specs:
ginseng-fediverse (1.8.15)
ginseng-fediverse (1.8.16)

GIT
remote: https://github.com/pooza/ginseng-postgres.git
Expand Down Expand Up @@ -170,8 +170,9 @@ GEM
etc (1.4.3)
eventmachine (1.2.7)
facets (3.1.0)
faraday (2.9.2)
faraday (2.10.0)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-net_http (3.1.0)
net-http
fastimage (2.3.1)
Expand All @@ -183,7 +184,7 @@ GEM
fugit (1.11.0)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
gli (2.21.1)
gli (2.21.5)
hashie (5.0.0)
http-cookie (1.0.6)
domain_name (~> 0.5)
Expand All @@ -194,11 +195,12 @@ GEM
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
json-schema (4.3.0)
json-schema (4.3.1)
addressable (>= 2.8)
jwt (2.8.2)
base64
language_server-protocol (3.17.0.3)
logger (1.6.0)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -211,11 +213,11 @@ GEM
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0702)
mini_magick (4.13.1)
mini_magick (5.0.0)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.24.1)
mongo (2.20.0)
mongo (2.20.1)
bson (>= 4.14.1, < 6.0.0)
multi_json (1.15.0)
multi_xml (0.7.1)
Expand All @@ -229,6 +231,7 @@ GEM
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.0)
Expand Down Expand Up @@ -258,7 +261,7 @@ GEM
omniauth (~> 2.0)
optparse (0.5.0)
parallel (1.25.1)
parser (3.3.3.0)
parser (3.3.4.0)
ast (~> 2.4.1)
racc
pg (1.5.6)
Expand All @@ -268,7 +271,7 @@ GEM
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.8.0)
rack (3.1.6)
rack (3.1.7)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
Expand Down Expand Up @@ -297,7 +300,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.1)
rexml (3.3.2)
strscan
ricecream (0.2.1)
rspotify (2.12.2)
Expand All @@ -306,20 +309,20 @@ GEM
rest-client (~> 2.0.2)
rss (0.3.0)
rexml
rubocop (1.64.1)
rubocop (1.65.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-minitest (0.35.0)
rubocop-minitest (0.35.1)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.1)
Expand Down Expand Up @@ -429,7 +432,7 @@ DEPENDENCIES
yamllint

RUBY VERSION
ruby 3.3.3p89
ruby 3.3.4p94

BUNDLED WITH
2.5.14
2.5.16
1 change: 0 additions & 1 deletion app/lib/mulukhiya.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def self.rack
end
end
Sidekiq::Web.use(Rack::Session::Cookie, {
secret: Crypt.password,
same_site: true,
max_age: Config.instance['/sidekiq/dashboard/session/max_age'],
})
Expand Down
16 changes: 0 additions & 16 deletions app/lib/mulukhiya/contract/growi_clipping_command_contract.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/lib/mulukhiya/contract/user_config_command_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ class UserConfigCommandContract < Contract
optional(:token).maybe(:string)
optional(:visibility).maybe(:string)
end
required(:growi).maybe(:hash).schema do
optional(:url).maybe(:string)
optional(:token).maybe(:string)
optional(:prefix).maybe(:string)
end
required(:annict).maybe(:hash).schema do
optional(:token).maybe(:string)
end
Expand Down Expand Up @@ -41,15 +36,10 @@ class UserConfigCommandContract < Contract
key.failure('コマンドが正しくありません。') unless value == 'user_config'
end

rule(:growi) do
key.failure('URLが正しくありません。') if value[:url] && !Ginseng::URI.parse(value[:url]).absolute?
end

def call(values)
values = values.deep_stringify_keys || {}
values['tags'] ||= []
values['webhook'] ||= {}
values['growi'] ||= {}
values['notify'] ||= {}
values['annict'] ||= {}
values['lemmy'] ||= {}
Expand Down
4 changes: 0 additions & 4 deletions app/lib/mulukhiya/controller_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ def oauth_callback?
return config["/#{name}/oauth/callback/enable"] == true rescue false
end

def growi?
return Handler.search(/growi/).present?
end

def lemmy?
return Handler.search(/lemmy/).present?
end
Expand Down
6 changes: 6 additions & 0 deletions app/lib/mulukhiya/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def self.hash_tag_class
return nil
end

def self.poll_class
return "Mulukhiya::#{controller_name.camelize}::Poll".constantize
rescue NameError
return nil
end

def self.sns_service_class
return "Mulukhiya::#{controller_name.camelize}Service".constantize
rescue NameError
Expand Down
15 changes: 0 additions & 15 deletions app/lib/mulukhiya/handler/growi_announce_handler.rb

This file was deleted.

13 changes: 0 additions & 13 deletions app/lib/mulukhiya/handler/growi_bookmark_handler.rb

This file was deleted.

15 changes: 0 additions & 15 deletions app/lib/mulukhiya/handler/growi_clipping_command_handler.rb

This file was deleted.

14 changes: 0 additions & 14 deletions app/lib/mulukhiya/model/account_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@ def webhook
return nil
end

def growi
return nil unless [:url, :token].all? {|k| user_config["/growi/#{k}"]}
default_prefix = File.join('/', Package.short_name, 'user', username)
@growi ||= GrowiClipper.new(
uri: user_config['/growi/url'],
token: user_config['/growi/token'],
prefix: user_config['/growi/prefix'] || default_prefix,
)
return @growi
rescue => e
e.log(acct: acct.to_s)
return nil
end

def lemmy
return nil unless [:url, :user, :password].all? {|k| user_config["/lemmy/#{k}"]}
@lemmy ||= LemmyClipper.new(
Expand Down
11 changes: 11 additions & 0 deletions app/lib/mulukhiya/model/misskey/poll.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Mulukhiya
module Misskey
class Poll < Sequel::Model(:poll)
one_to_one :status, key: :noteId

def choices
return values[:choices].match(/\{(.*)\}/)[1].split(',')
end
end
end
end
17 changes: 17 additions & 0 deletions app/lib/mulukhiya/model/misskey/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def updatable_by?(target)
return account&.id == target&.id
end

def poll
return nil unless hasPoll
return Poll[id]
end

def attachments
@attachments ||= fileIds.match(/\{(.*)\}/)[1].split(',').map do |id|
Attachment[id]
Expand All @@ -50,6 +55,18 @@ def attachments

alias visibility_name visibility

def payload
payload = values.slice(
reply_to_field.to_sym,
spoiler_field.to_sym,
visibility_field.to_sym,
poll_field.to_sym => poll&.choices,
)
payload[status_field.to_sym] = text
payload[attachment_field.to_sym] = attachments.map(&:id).to_a
return payload
end

def to_md
return uri.to_md
rescue => e
Expand Down
4 changes: 4 additions & 0 deletions app/lib/mulukhiya/model/status_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def data
return @data
end

def poll
return nil
end

def webui_uri
@webui_uri ||= service.create_uri("/mulukhiya/app/status/#{id}")
return @webui_uri
Expand Down
25 changes: 0 additions & 25 deletions app/lib/mulukhiya/service/growi_clipper.rb

This file was deleted.

4 changes: 2 additions & 2 deletions app/lib/mulukhiya/service/lemmy_clipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def login
end

def clip(body)
login
login unless @jwt
body ||= {}
body.deep_symbolize_keys!
raise Ginseng::RequestError, 'invalid community' unless @params[:community]
Expand All @@ -58,7 +58,7 @@ def clip(body)
end

def communities
login
login unless @jwt
uri = self.uri.clone
uri.path = '/api/v3/community/list'
uri.query_values = {
Expand Down
1 change: 1 addition & 0 deletions app/lib/mulukhiya/service/mastodon_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def update_status(status, body, params = {})
body.deep_symbolize_keys!
body[:spoiler_text] ||= status.spoiler_text
body[:visibility] ||= status.visibility_name
body[:media_ids] ||= status.attachments.map {|v| v.id.to_s}
super(status.id, body, params)
return status.to_h.merge(
account: status.account.to_h.slice(:username, :display_name),
Expand Down
Loading

0 comments on commit 681689d

Please sign in to comment.