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
cca17856
Unverified
Commit
cca17856
authored
2 weeks ago
by
Sumner Evans
Browse files
Options
Downloads
Patches
Plain Diff
sync: add limit configurations
Signed-off-by:
Sumner Evans
<
sumner.evans@automattic.com
>
parent
85ca2b6b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#16594
passed
2 weeks ago
Stage: build
Stage: build docker
Stage: manifest
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/connector/config.go
+7
-0
7 additions, 0 deletions
pkg/connector/config.go
pkg/connector/example-config.yaml
+9
-0
9 additions, 0 deletions
pkg/connector/example-config.yaml
pkg/connector/sync.go
+20
-2
20 additions, 2 deletions
pkg/connector/sync.go
with
36 additions
and
2 deletions
pkg/connector/config.go
+
7
−
0
View file @
cca17856
...
...
@@ -31,6 +31,11 @@ var ExampleConfig string
type
Config
struct
{
DisplaynameTemplate
string
`yaml:"displayname_template"`
displaynameTemplate
*
template
.
Template
`yaml:"-"`
Sync
struct
{
UpdateLimit
int
`yaml:"update_limit"`
CreateLimit
int
`yaml:"create_limit"`
}
`yaml:"sync"`
}
type
umConfig
Config
...
...
@@ -50,6 +55,8 @@ func (c *Config) PostProcess() (err error) {
func
upgradeConfig
(
helper
up
.
Helper
)
{
helper
.
Copy
(
up
.
Str
,
"displayname_template"
)
helper
.
Copy
(
up
.
Int
,
"sync"
,
"update_limit"
)
helper
.
Copy
(
up
.
Int
,
"sync"
,
"create_limit"
)
}
func
(
lc
*
LinkedInConnector
)
GetConfig
()
(
string
,
any
,
up
.
Upgrader
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/connector/example-config.yaml
+
9
−
0
View file @
cca17856
...
...
@@ -2,3 +2,12 @@
# .FirstName is replaced with the first name
# .LastName is replaced with the last name
displayname_template
:
"
{{
with
.Organization
}}{{
.
}}{{
else
}}{{
.FirstName
}}
{{
.LastName
}}{{
end
}}
(LinkedIn)"
sync
:
# Number of most recently active dialogs to check when syncing chats.
# Set to 0 to remove limit.
update_limit
:
0
# Number of most recently active dialogs to create portals for when syncing
# chats.
# Set to 0 to remove limit.
create_limit
:
10
This diff is collapsed.
Click to expand it.
pkg/connector/sync.go
+
20
−
2
View file @
cca17856
...
...
@@ -17,6 +17,7 @@ func (l *LinkedInClient) syncConversations(ctx context.Context) {
lastUsedUpdatedBefore
:=
time
.
Time
{}
updatedBefore
:=
time
.
Now
()
var
updated
,
created
int
for
{
log
:=
log
.
With
()
.
Time
(
"updated_before"
,
updatedBefore
)
.
...
...
@@ -45,13 +46,25 @@ func (l *LinkedInClient) syncConversations(ctx context.Context) {
updatedBefore
=
conv
.
LastActivityAt
.
Time
}
portalKey
:=
l
.
makePortalKey
(
conv
.
EntityURN
)
portal
,
err
:=
l
.
main
.
Bridge
.
GetPortalByKey
(
ctx
,
portalKey
)
if
err
!=
nil
{
log
.
Err
(
err
)
.
Msg
(
"Failed to get portal"
)
continue
}
meta
:=
simplevent
.
EventMeta
{
LogContext
:
func
(
c
zerolog
.
Context
)
zerolog
.
Context
{
return
c
.
Str
(
"update"
,
"sync"
)
},
PortalKey
:
l
.
makePortalKey
(
conv
.
EntityURN
),
CreatePortal
:
true
,
PortalKey
:
portalKey
,
CreatePortal
:
l
.
main
.
Config
.
Sync
.
CreateLimit
==
0
||
created
<=
l
.
main
.
Config
.
Sync
.
CreateLimit
,
}
if
portal
==
nil
||
portal
.
MXID
==
""
{
created
++
}
updated
++
var
latestMessageTS
time
.
Time
for
_
,
msg
:=
range
conv
.
Messages
.
Elements
{
...
...
@@ -64,6 +77,11 @@ func (l *LinkedInClient) syncConversations(ctx context.Context) {
EventMeta
:
meta
.
WithType
(
bridgev2
.
RemoteEventChatResync
),
LatestMessageTS
:
latestMessageTS
,
})
if
l
.
main
.
Config
.
Sync
.
UpdateLimit
>
0
&&
updated
>=
l
.
main
.
Config
.
Sync
.
UpdateLimit
{
log
.
Info
()
.
Msg
(
"Update limit reached"
)
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