Commit 9e093c1c by mingyuan

support send notication

parent 6d0d1f1d
...@@ -5,7 +5,6 @@ gemspec ...@@ -5,7 +5,6 @@ gemspec
gem 'pg' gem 'pg'
gem 'puma' gem 'puma'
gem 'sidekiq' gem 'sidekiq'
gem 'jbuilder'
gem 'viter', github: 'qinmingyuan/viter' gem 'viter', github: 'qinmingyuan/viter'
gem 'rails_design', github: 'work-design/rails_design' gem 'rails_design', github: 'work-design/rails_design'
......
GIT GIT
remote: https://github.com/qinmingyuan/viter.git remote: https://github.com/qinmingyuan/viter.git
revision: a6c36456e695b32d427179c1bfc1c0df2c66792c revision: 82d46c2eed89cc27b89811e3ded0cb6797f3b807
specs: specs:
viter (0.1) viter (0.1)
rails rails
GIT GIT
remote: https://github.com/work-design/rails_com.git remote: https://github.com/work-design/rails_com.git
revision: 2648f2003f88d86ff730d9e478ea4d1e63355280 revision: 2377ede7104b675247bf7b26bc279591d54d0a21
specs: specs:
rails_com (1.2.9) rails_com (1.2.9)
acme-client acme-client
...@@ -16,6 +16,7 @@ GIT ...@@ -16,6 +16,7 @@ GIT
default_where (~> 2.2) default_where (~> 2.2)
http-form_data (~> 2.3) http-form_data (~> 2.3)
httpx (~> 0.16) httpx (~> 0.16)
jbuilder
kaminari kaminari
rails (>= 6.1) rails (>= 6.1)
rails_extend rails_extend
...@@ -23,14 +24,14 @@ GIT ...@@ -23,14 +24,14 @@ GIT
GIT GIT
remote: https://github.com/work-design/rails_design.git remote: https://github.com/work-design/rails_design.git
revision: 092a58af67ee302612df8cb5416149f6b9c7890a revision: 383e4a7423663c8233b14d1eeaec2507569310ca
specs: specs:
rails_design (0.0.1) rails_design (0.0.1)
rails rails
GIT GIT
remote: https://github.com/work-design/rails_extend.git remote: https://github.com/work-design/rails_extend.git
revision: ada7e86e1319e0181221e021e97668075a3910a4 revision: c51aad1277fff57c53409a2c4c6c4e90461463d5
specs: specs:
rails_extend (1.0.0) rails_extend (1.0.0)
rails (>= 5.0) rails (>= 5.0)
...@@ -123,7 +124,7 @@ GEM ...@@ -123,7 +124,7 @@ GEM
default_where (2.3.0) default_where (2.3.0)
activerecord (>= 4.0, <= 7.0) activerecord (>= 4.0, <= 7.0)
erubi (1.10.0) erubi (1.10.0)
faraday (1.7.2) faraday (1.8.0)
faraday-em_http (~> 1.0) faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0) faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1) faraday-excon (~> 1.1)
...@@ -239,7 +240,7 @@ GEM ...@@ -239,7 +240,7 @@ GEM
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
thor (1.1.0) thor (1.1.0)
timers (4.3.3) timers (4.3.3)
turbo-rails (0.7.11) turbo-rails (0.7.14)
rails (>= 6.0.0) rails (>= 6.0.0)
tzinfo (2.0.4) tzinfo (2.0.4)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
...@@ -259,7 +260,6 @@ PLATFORMS ...@@ -259,7 +260,6 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
amazing_print amazing_print
debug debug
jbuilder
minitest-hooks minitest-hooks
pg pg
puma puma
......
module Dingtalk::Api module Dingtalk::Api
class Base class Base
BASE = 'https://oapi.dingtalk.com/'
attr_reader :app, :client attr_reader :app, :client
def initialize(app) def initialize(app)
......
module Dingtalk::Api module Dingtalk::Api
module Inner::Saas module Inner::Saas
BASE = 'https://openplatform-pro.ding.zj.gov.cn'
def getuserinfo(code) def getuserinfo(code)
r = post '/rpc/oauth2/dingtalk_app_user.json', auth_code: code, base: BASE r = post '/rpc/oauth2/dingtalk_app_user.json', auth_code: code
if r.is_a? Hash if r.is_a? Hash
r.dig('content', 'data') r.dig('content', 'data')
...@@ -20,7 +19,28 @@ module Dingtalk::Api ...@@ -20,7 +19,28 @@ module Dingtalk::Api
mobile: mobile mobile: mobile
} }
r = post '/mozi/employee/get_by_mobile', **payload, base: BASE r = post '/mozi/employee/get_by_mobile', **payload
if r.is_a? Hash
r.dig('content', 'data')
else
r
end
end
def text_notification(receiver_ids = [], text = '')
payload = {
receiverIds: Array(receiver_ids).join(','),
tenantId: app.tenant_id,
msg: {
msgtype: 'text',
text: {
content: text
}
}
}
r = post '/message/workNotification', **payload
if r.is_a? Hash if r.is_a? Hash
r.dig('content', 'data') r.dig('content', 'data')
......
...@@ -20,6 +20,9 @@ module Dingtalk ...@@ -20,6 +20,9 @@ module Dingtalk
belongs_to :saas_app, foreign_key: :appid, primary_key: :app_key, optional: true belongs_to :saas_app, foreign_key: :appid, primary_key: :app_key, optional: true
end end
def text_notification(text = '')
saas_app.api.text_notification(text)
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment