comparison libervia/backend/plugins/plugin_misc_extra_pep.py @ 4071:4b842c1fb686

refactoring: renamed `sat` package to `libervia.backend`
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 11:49:51 +0200
parents sat/plugins/plugin_misc_extra_pep.py@524856bd7b19
children 0d7bb4df2343
comparison
equal deleted inserted replaced
4070:d10748475025 4071:4b842c1fb686
1 #!/usr/bin/env python3
2
3
4 # SAT plugin for displaying messages from extra PEP services
5 # Copyright (C) 2015 Adrien Cossa (souliane@mailoo.org)
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
16
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 from libervia.backend.core.i18n import _, D_
21 from libervia.backend.core.constants import Const as C
22 from libervia.backend.core.log import getLogger
23
24 log = getLogger(__name__)
25 from libervia.backend.memory import params
26 from twisted.words.protocols.jabber import jid
27
28
29 PLUGIN_INFO = {
30 C.PI_NAME: "Extra PEP",
31 C.PI_IMPORT_NAME: "EXTRA-PEP",
32 C.PI_TYPE: "MISC",
33 C.PI_PROTOCOLS: [],
34 C.PI_DEPENDENCIES: [],
35 C.PI_RECOMMENDATIONS: [],
36 C.PI_MAIN: "ExtraPEP",
37 C.PI_HANDLER: "no",
38 C.PI_DESCRIPTION: _("""Display messages from extra PEP services"""),
39 }
40
41
42 PARAM_KEY = "Misc"
43 PARAM_NAME = "blogs"
44 PARAM_LABEL = "Blog authors following list"
45 PARAM_DEFAULT = (jid.JID("salut-a-toi@libervia.org"),)
46
47
48 class ExtraPEP(object):
49
50 params = """
51 <params>
52 <individual>
53 <category name="%(category_name)s" label="%(category_label)s">
54 <param name="%(param_name)s" label="%(param_label)s" type="jids_list" security="0">
55 %(jids)s
56 </param>
57 </category>
58 </individual>
59 </params>
60 """ % {
61 "category_name": PARAM_KEY,
62 "category_label": D_(PARAM_KEY),
63 "param_name": PARAM_NAME,
64 "param_label": D_(PARAM_LABEL),
65 "jids": "\n".join({elt.toXml() for elt in params.create_jid_elts(PARAM_DEFAULT)}),
66 }
67
68 def __init__(self, host):
69 log.info(_("Plugin Extra PEP initialization"))
70 self.host = host
71 host.memory.update_params(self.params)
72
73 def get_followed_entities(self, profile_key):
74 return self.host.memory.param_get_a(PARAM_NAME, PARAM_KEY, profile_key=profile_key)