Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
204
Issues
204
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
poezio
Commits
5cfb0cbf
Commit
5cfb0cbf
authored
Jan 22, 2021
by
ge0rg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugins/contact: iterate all data forms, thx. mathieui
parent
12ab0a7e
Pipeline
#3564
failed with stages
in 5 minutes
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
plugins/contact.py
plugins/contact.py
+14
-17
No files found.
plugins/contact.py
View file @
5cfb0cbf
...
...
@@ -32,25 +32,22 @@ class Plugin(BasePlugin):
self
.
api
.
information
(
message
,
'Error'
)
return
info
=
iq
[
'disco_info'
]
title
=
'Contact Info'
contacts
=
[]
for
field
in
info
[
'form'
]:
var
=
field
[
'var'
]
if
field
[
'type'
]
==
'hidden'
and
var
==
'FORM_TYPE'
:
form_type
=
field
[
'value'
][
0
]
if
form_type
!=
'http://jabber.org/network/serverinfo'
:
self
.
api
.
information
(
'Not a server: “%s”: %s'
%
(
iq
[
'from'
],
form_type
),
'Error'
)
return
continue
if
not
var
.
endswith
(
'-addresses'
):
continue
var
=
var
[:
-
10
]
# strip '-addresses'
sep
=
'
\n
'
+
len
(
var
)
*
' '
field_value
=
field
.
get_value
(
convert
=
False
)
value
=
sep
.
join
(
field_value
)
if
isinstance
(
field_value
,
list
)
else
field_value
contacts
.
append
(
'%s: %s'
%
(
var
,
value
))
# iterate all data forms, in case there are multiple
for
form
in
iq
[
'disco_info'
]:
values
=
form
.
get_values
()
if
values
[
'FORM_TYPE'
][
0
]
==
'http://jabber.org/network/serverinfo'
:
for
var
in
values
:
if
not
var
.
endswith
(
'-addresses'
):
continue
title
=
var
[:
-
10
]
# strip '-addresses'
sep
=
'
\n
'
+
len
(
title
)
*
' '
field_value
=
values
[
var
]
if
field_value
:
value
=
sep
.
join
(
field_value
)
if
isinstance
(
field_value
,
list
)
else
field_value
contacts
.
append
(
'%s: %s'
%
(
title
,
value
))
if
contacts
:
self
.
api
.
information
(
'
\n
'
.
join
(
contacts
),
title
)
self
.
api
.
information
(
'
\n
'
.
join
(
contacts
),
'Contact Info'
)
else
:
self
.
api
.
information
(
'No Contact Addresses for %s'
%
iq
[
'from'
],
'Error'
)
...
...
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