Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dingtalk-sdk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
dingtalk-sdk
Commits
688eb432
Commit
688eb432
authored
Oct 30, 2020
by
Francis Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix at_mobiles generated hash
parent
07d8eeec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
14 deletions
+8
-14
robot.rb
lib/dingtalk_sdk/robot.rb
+4
-9
robot_spec.rb
spec/dingtalk_sdk/robot_spec.rb
+4
-5
No files found.
lib/dingtalk_sdk/robot.rb
View file @
688eb432
# frozen_string_literal: true
require
'json'
require
'base64'
require
'openssl'
require
'dingtalk_sdk'
...
...
@@ -117,9 +116,9 @@ module DingtalkSdk
}
end
def
at_mobile
(
mobile
)
def
at_mobile
s
(
mobiles
)
@is_at_all
=
false
@at_mobile_list
=
[
*
mobile
].
map
(
&
:to_s
).
uniq
@at_mobile_list
=
[
*
mobile
s
].
map
(
&
:to_s
).
uniq
end
def
at_all
...
...
@@ -132,16 +131,12 @@ module DingtalkSdk
h
.
merge!
@mesg
if
@is_at_all
h
[
:
isAtAll
]
=
true
h
[
:
at
]
=
{
isAtAll:
true
}
elsif
@at_mobile_list
.
try
(
:size
).
try
(
:positive?
)
h
[
:at
Mobiles
]
=
@at_mobile_list
h
[
:at
]
=
{
isAtAll:
false
,
atMobiles:
@at_mobile_list
}
end
end
end
def
to_json
(
*
_args
)
JSON
.
generate
to_h
end
end
end
end
spec/dingtalk_sdk/robot_spec.rb
View file @
688eb432
...
...
@@ -38,18 +38,17 @@ RSpec.describe DingtalkSdk::Robot do
expect
(
mesg_h
[
:msgtype
]).
to
eq
(
'text'
)
expect
(
mesg_h
[
:text
][
:content
]).
to
eq
(
'hello world'
)
expect
(
mesg_h
[
:isAtAll
]).
to
be_nil
expect
(
mesg_h
[
:atMobiles
]).
to
be_nil
expect
(
mesg_h
[
:at
]).
to
be_nil
end
it
'should compose message with at mobiles'
do
builder
=
DingtalkSdk
::
Robot
::
MessageBuilder
.
new
builder
.
text
text:
'hello world'
builder
.
at_mobile
[
123
,
456
]
builder
.
at_mobile
s
[
123
,
456
]
mesg_h
=
builder
.
to_h
expect
(
mesg_h
[
:isAtAll
]).
to
be_nil
expect
(
mesg_h
[
:atMobiles
]).
to
eq
(
%w[123 456]
)
expect
(
mesg_h
[
:
at
][
:
isAtAll
]).
to
be_nil
expect
(
mesg_h
[
:at
][
:at
Mobiles
]).
to
eq
(
%w[123 456]
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment