plugin XEP-0346: "Form Discovery and Publishing" implementation:
this implementation replaces the former non standard node schema, and works in a similar way (the schema is put in a separated node instead of a special field, thus it will now work with most/all PubSub services, and not only SàT PubSub). The implementation has been done in a way that nothing should be changed in frontends (bridge methods names and arguments stay the same). The nodes are modified, but if values are taken from backend, it's automatically adapted.
This commit is contained in:
parent
df6f87d69a
commit
968ee50d31
1 changed files with 158 additions and 134 deletions
|
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# SAT plugin for Pubsub Schemas
|
||||
# Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -25,27 +24,29 @@ from sat.core.log import getLogger
|
|||
|
||||
log = getLogger(__name__)
|
||||
|
||||
NS_TICKETS = "org.salut-a-toi.tickets:0"
|
||||
APP_NS_TICKETS = "org.salut-a-toi.tickets:0"
|
||||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: _("Tickets management"),
|
||||
C.PI_IMPORT_NAME: "TICKETS",
|
||||
C.PI_TYPE: "EXP",
|
||||
C.PI_PROTOCOLS: [],
|
||||
C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "XEP-0277", "IDENTITY"],
|
||||
C.PI_DEPENDENCIES: ["XEP-0060", "XEP-0346", "XEP-0277", "IDENTITY"],
|
||||
C.PI_MAIN: "Tickets",
|
||||
C.PI_HANDLER: "no",
|
||||
C.PI_DESCRIPTION: _("""Tickets management plugin"""),
|
||||
}
|
||||
|
||||
|
||||
class Tickets(object):
|
||||
class Tickets:
|
||||
|
||||
def __init__(self, host):
|
||||
log.info(_("Tickets plugin initialization"))
|
||||
self.host = host
|
||||
host.registerNamespace("tickets", NS_TICKETS)
|
||||
self._s = self.host.plugins["XEP-0346"]
|
||||
self.namespace = self._s.getSubmittedNS(APP_NS_TICKETS)
|
||||
host.registerNamespace("tickets", self.namespace)
|
||||
self._p = self.host.plugins["XEP-0060"]
|
||||
self._s = self.host.plugins["PUBSUB_SCHEMA"]
|
||||
self._m = self.host.plugins["XEP-0277"]
|
||||
host.bridge.addMethod(
|
||||
"ticketsGet",
|
||||
|
|
@ -60,8 +61,8 @@ class Tickets(object):
|
|||
items_ids,
|
||||
sub_id,
|
||||
extra,
|
||||
default_node=NS_TICKETS,
|
||||
form_ns=NS_TICKETS,
|
||||
default_node=self.namespace,
|
||||
form_ns=APP_NS_TICKETS,
|
||||
filters={
|
||||
"author": self._s.valueOrPublisherFilter,
|
||||
"created": self._s.dateFilter,
|
||||
|
|
@ -84,7 +85,7 @@ class Tickets(object):
|
|||
in_sign="sss",
|
||||
out_sign="s",
|
||||
method=lambda service, nodeIdentifier, profile_key: self._s._getUISchema(
|
||||
service, nodeIdentifier, default_node=NS_TICKETS,
|
||||
service, nodeIdentifier, default_node=self.namespace,
|
||||
profile_key=profile_key),
|
||||
async_=True,
|
||||
)
|
||||
|
|
@ -101,7 +102,7 @@ class Tickets(object):
|
|||
return d
|
||||
|
||||
async def set(self, client, service, node, values, schema=None, item_id=None, extra=None,
|
||||
deserialise=False, form_ns=NS_TICKETS):
|
||||
deserialise=False, form_ns=APP_NS_TICKETS):
|
||||
"""Publish a tickets
|
||||
|
||||
@param node(unicode, None): Pubsub node to use
|
||||
|
|
@ -119,7 +120,7 @@ class Tickets(object):
|
|||
@return (unicode): id of the created item
|
||||
"""
|
||||
if not node:
|
||||
node = NS_TICKETS
|
||||
node = self.namespace
|
||||
|
||||
if not item_id:
|
||||
comments_service = await self._m.getCommentsService(client, service)
|
||||
|
|
|
|||
Loading…
Reference in a new issue