Coverage for slidge/slixfix/xep_0356_old/stanza.py: 69%

32 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-07 05:11 +0000

1from slixmpp.plugins.xep_0297 import Forwarded 

2from slixmpp.stanza import Message 

3from slixmpp.xmlstream import ElementBase, register_stanza_plugin 

4 

5 

6class PrivilegeOld(ElementBase): 

7 namespace = "urn:xmpp:privilege:1" 

8 name = "privilege" 

9 plugin_attrib = "privilege_old" 

10 

11 def permission(self, access): 

12 for perm in self["perms"]: 

13 if perm["access"] == access: 

14 return perm["type"] 

15 

16 def roster(self): 

17 return self.permission("roster") 

18 

19 def message(self): 

20 return self.permission("message") 

21 

22 def presence(self): 

23 return self.permission("presence") 

24 

25 def add_perm(self, access, type): 

26 # This should only be needed for servers, so maybe out of scope for slixmpp 

27 perm = PermOld() 

28 perm["type"] = type 

29 perm["access"] = access 

30 self.append(perm) 

31 

32 

33class PermOld(ElementBase): 

34 namespace = "urn:xmpp:privilege:1" 

35 name = "perm" 

36 plugin_attrib = "perm" 

37 plugin_multi_attrib = "perms" 

38 interfaces = {"type", "access"} 

39 

40 

41def register(): 

42 register_stanza_plugin(Message, PrivilegeOld) 

43 register_stanza_plugin(PrivilegeOld, Forwarded) 

44 register_stanza_plugin(PrivilegeOld, PermOld, iterable=True)