Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
helpdesk_gitlab
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
helpdesk_gitlab
Commits
6db97d40
Commit
6db97d40
authored
May 6, 2024
by
Daniel Speicher
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3444639
: Synchronize Users
parent
3a9ccb83
No related branches found
No related tags found
No related merge requests found
Pipeline
#165583
failed
May 6, 2024
Stage: build
Stage: validate
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/HelpdeskIntegration/GitLab.php
+25
-36
25 additions, 36 deletions
src/Plugin/HelpdeskIntegration/GitLab.php
with
25 additions
and
36 deletions
src/Plugin/HelpdeskIntegration/GitLab.php
+
25
−
36
View file @
6db97d40
...
@@ -26,7 +26,7 @@ class GitLab extends PluginBase {
...
@@ -26,7 +26,7 @@ class GitLab extends PluginBase {
use
StringTranslationTrait
;
use
StringTranslationTrait
;
const
PER_PAGE
=
100
;
const
int
PER_PAGE
=
100
;
/**
/**
* The GitLab client.
* The GitLab client.
...
@@ -35,20 +35,6 @@ class GitLab extends PluginBase {
...
@@ -35,20 +35,6 @@ class GitLab extends PluginBase {
*/
*/
private
?Client
$adminClient
=
NULL
;
private
?Client
$adminClient
=
NULL
;
/**
* The client for a specific user.
*
* @var \Gitlab\Client|null
*/
private
?Client
$userClient
=
NULL
;
/**
* The current impersonation token.
*
* @var string
*/
private
string
$currentImpersonationToken
;
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
@@ -133,9 +119,10 @@ class GitLab extends PluginBase {
...
@@ -133,9 +119,10 @@ class GitLab extends PluginBase {
if
(
$comment
[
'internal'
])
{
if
(
$comment
[
'internal'
])
{
continue
;
continue
;
}
}
$comment_id
=
$issue
->
addComment
(
$body
=
$this
->
filterMarkdownLinks
(
$comment
[
'body'
]);
$issue
->
addComment
(
$comment
[
'id'
],
$comment
[
'id'
],
$comment
[
'
body
'
]
,
htmlspecialchars_decode
(
$
body
)
,
$user
,
$user
,
strtotime
(
$comment
[
'created_at'
]),
strtotime
(
$comment
[
'created_at'
]),
strtotime
(
$comment
[
'updated_at'
])
strtotime
(
$comment
[
'updated_at'
])
...
@@ -148,6 +135,12 @@ class GitLab extends PluginBase {
...
@@ -148,6 +135,12 @@ class GitLab extends PluginBase {
return
$issues
;
return
$issues
;
}
}
private
function
filterMarkdownLinks
(
string
$text
):
string
{
return
preg_replace_callback
(
'/\[(.*?)]\((.*?)\)/'
,
function
(
$matches
)
{
return
'Here is an attachment which could not be downloaded.'
;
},
htmlspecialchars
(
$text
));
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
@@ -331,11 +324,7 @@ class GitLab extends PluginBase {
...
@@ -331,11 +324,7 @@ class GitLab extends PluginBase {
*/
*/
private
function
getUserClient
(
HelpdeskInterface
$helpdesk
,
int
$remoteUserId
):
Client
{
private
function
getUserClient
(
HelpdeskInterface
$helpdesk
,
int
$remoteUserId
):
Client
{
$token
=
$this
->
getUserImpersonationToken
(
$helpdesk
,
$remoteUserId
);
$token
=
$this
->
getUserImpersonationToken
(
$helpdesk
,
$remoteUserId
);
if
(
!
$this
->
userClient
||
$this
->
currentImpersonationToken
!==
$token
)
{
return
$this
->
doCreateClient
(
$helpdesk
,
$token
);
$this
->
userClient
=
$this
->
doCreateClient
(
$helpdesk
,
$token
);
$this
->
currentImpersonationToken
=
$token
;
}
return
$this
->
userClient
;
}
}
/**
/**
...
@@ -371,7 +360,7 @@ class GitLab extends PluginBase {
...
@@ -371,7 +360,7 @@ class GitLab extends PluginBase {
$tokens
=
$this
->
getAdminClient
(
$helpdesk
)
->
users
()
$tokens
=
$this
->
getAdminClient
(
$helpdesk
)
->
users
()
->
userImpersonationTokens
(
$remoteUserId
,
[
->
userImpersonationTokens
(
$remoteUserId
,
[
'state'
=>
'active'
,
'state'
=>
'active'
,
'per_page'
=>
100
,
'per_page'
=>
self
::
PER_PAGE
,
]);
]);
foreach
(
$tokens
as
$token
)
{
foreach
(
$tokens
as
$token
)
{
...
...
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