changeset 2421:b7e24ce97a06

plugin schema: separate lines of text-multi in different values as requested by XEP-0004
author Goffi <goffi@goffi.org>
date Sun, 05 Nov 2017 20:34:51 +0100
parents 03da3ef5fb5b
children 5425cf18929b
files src/plugins/plugin_exp_pubsub_schema.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_exp_pubsub_schema.py	Sun Nov 05 15:36:06 2017 +0100
+++ b/src/plugins/plugin_exp_pubsub_schema.py	Sun Nov 05 20:34:51 2017 +0100
@@ -32,6 +32,7 @@
 from zope.interface import implements
 from collections import Iterable
 import copy
+import itertools
 
 NS_SCHEMA = 'https://salut-a-toi/protocol/schema:0'
 
@@ -285,6 +286,10 @@
             if deserialise:
                 if field.fieldType == 'boolean':
                     values_list = [C.bool(v) for v in values_list]
+                elif field.fieldType == 'text-multi':
+                    # for text-multi, lines must be put on separate values
+                    values_list = list(itertools.chain(*[v.splitlines() for v in values_list]))
+
                 elif 'jid' in field.fieldType:
                     values_list = [jid.JID(v) for v in values_list]
             if 'list' in field.fieldType: