Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linkedin
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mautrix
linkedin
Commits
a9fc6d27
Unverified
Commit
a9fc6d27
authored
4 weeks ago
by
Sumner Evans
Browse files
Options
Downloads
Patches
Plain Diff
connector/matrixfmt: return a whole SendMessageBody
Signed-off-by:
Sumner Evans
<
sumner.evans@automattic.com
>
parent
c20b435d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#16454
passed
4 weeks ago
Stage: build
Stage: build docker
Stage: manifest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/connector/client.go
+1
-6
1 addition, 6 deletions
pkg/connector/client.go
pkg/connector/matrixfmt/convert.go
+10
-11
10 additions, 11 deletions
pkg/connector/matrixfmt/convert.go
with
11 additions
and
17 deletions
pkg/connector/client.go
+
1
−
6
View file @
a9fc6d27
...
@@ -356,14 +356,9 @@ func (l *LinkedInClient) GetUserInfo(ctx context.Context, ghost *bridgev2.Ghost)
...
@@ -356,14 +356,9 @@ func (l *LinkedInClient) GetUserInfo(ctx context.Context, ghost *bridgev2.Ghost)
func
(
l
*
LinkedInClient
)
HandleMatrixMessage
(
ctx
context
.
Context
,
msg
*
bridgev2
.
MatrixMessage
)
(
*
bridgev2
.
MatrixMessageResponse
,
error
)
{
func
(
l
*
LinkedInClient
)
HandleMatrixMessage
(
ctx
context
.
Context
,
msg
*
bridgev2
.
MatrixMessage
)
(
*
bridgev2
.
MatrixMessageResponse
,
error
)
{
conversationURN
:=
types
.
NewURN
(
string
(
msg
.
Portal
.
ID
))
conversationURN
:=
types
.
NewURN
(
string
(
msg
.
Portal
.
ID
))
message
,
attrs
:=
matrixfmt
.
Parse
(
ctx
,
l
.
matrixParser
,
msg
.
Content
)
sendMessagePayload
:=
linkedingo
.
SendMessagePayload
{
sendMessagePayload
:=
linkedingo
.
SendMessagePayload
{
Message
:
linkedingo
.
SendMessage
{
Message
:
linkedingo
.
SendMessage
{
Body
:
linkedingo
.
SendMessageBody
{
Body
:
matrixfmt
.
Parse
(
ctx
,
l
.
matrixParser
,
msg
.
Content
),
Attributes
:
attrs
,
Text
:
message
,
},
ConversationURN
:
conversationURN
,
ConversationURN
:
conversationURN
,
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
pkg/connector/matrixfmt/convert.go
+
10
−
11
View file @
a9fc6d27
...
@@ -48,27 +48,26 @@ func toLinkedInAttribute(br linkedinfmt.BodyRange) linkedingo.SendMessageAttribu
...
@@ -48,27 +48,26 @@ func toLinkedInAttribute(br linkedinfmt.BodyRange) linkedingo.SendMessageAttribu
}
}
}
}
func
Parse
(
ctx
context
.
Context
,
parser
*
HTMLParser
,
content
*
event
.
MessageEventContent
)
(
string
,
[]
linkedingo
.
SendMessage
Attribute
)
{
func
Parse
(
ctx
context
.
Context
,
parser
*
HTMLParser
,
content
*
event
.
MessageEventContent
)
(
body
linkedingo
.
SendMessage
Body
)
{
if
content
.
MsgType
.
IsMedia
()
&&
(
content
.
FileName
==
""
||
content
.
FileName
==
content
.
Body
)
{
if
content
.
MsgType
.
IsMedia
()
&&
(
content
.
FileName
==
""
||
content
.
FileName
==
content
.
Body
)
{
// The body is the filename.
// The body is the filename.
return
""
,
nil
return
}
}
if
content
.
Format
!=
event
.
FormatHTML
{
if
content
.
Format
!=
event
.
FormatHTML
{
return
content
.
Body
,
nil
body
.
Text
=
content
.
Body
return
}
}
parseCtx
:=
NewContext
(
ctx
)
parseCtx
:=
NewContext
(
ctx
)
parseCtx
.
AllowedMentions
=
content
.
Mentions
parseCtx
.
AllowedMentions
=
content
.
Mentions
parsed
:=
parser
.
Parse
(
content
.
FormattedBody
,
parseCtx
)
parsed
:=
parser
.
Parse
(
content
.
FormattedBody
,
parseCtx
)
if
parsed
==
nil
{
if
parsed
==
nil
{
return
""
,
nil
return
}
}
var
entities
[]
linkedingo
.
SendMessageAttribute
body
.
Text
=
parsed
.
String
.
String
()
if
len
(
parsed
.
Entities
)
>
0
{
body
.
Attributes
=
make
([]
linkedingo
.
SendMessageAttribute
,
len
(
parsed
.
Entities
))
entities
=
make
([]
linkedingo
.
SendMessageAttribute
,
len
(
parsed
.
Entities
))
for
i
,
ent
:=
range
parsed
.
Entities
{
for
i
,
ent
:=
range
parsed
.
Entities
{
body
.
Attributes
[
i
]
=
toLinkedInAttribute
(
ent
)
entities
[
i
]
=
toLinkedInAttribute
(
ent
)
}
}
}
return
parsed
.
String
.
String
(),
entities
return
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment