Merge branch 'xep-0461-fixes' into 'master'

XEP-0461: fixes

See merge request poezio/slixmpp!233
This commit is contained in:
Maxime Buquet 2023-02-23 23:42:19 +00:00
commit de7b2d33a3
3 changed files with 7 additions and 7 deletions

View file

@ -13,7 +13,7 @@ class Reply(ElementBase):
class FeatureFallBack(ElementBase): class FeatureFallBack(ElementBase):
# should also be a multi attrib # should also be a multi attrib
namespace = "urn:xmpp:feature-fallback:0" namespace = "urn:xmpp:fallback:0"
name = "fallback" name = "fallback"
plugin_attrib = "feature_fallback" plugin_attrib = "feature_fallback"
interfaces = {"for"} interfaces = {"for"}
@ -24,7 +24,7 @@ class FeatureFallBack(ElementBase):
end = self["fallback_body"]["end"] end = self["fallback_body"]["end"]
body = self.parent()["body"] body = self.parent()["body"]
if start <= end: if start <= end:
return body[start:end+1] return body[start:end]
else: else:
return "" return ""
@ -44,7 +44,7 @@ class FeatureFallBack(ElementBase):
msg["body"] = quoted + msg["body"] msg["body"] = quoted + msg["body"]
msg["feature_fallback"]["for"] = NS msg["feature_fallback"]["for"] = NS
msg["feature_fallback"]["fallback_body"]["start"] = 0 msg["feature_fallback"]["fallback_body"]["start"] = 0
msg["feature_fallback"]["fallback_body"]["end"] = len(quoted) - 1 msg["feature_fallback"]["fallback_body"]["end"] = len(quoted)
class FallBackBody(ElementBase): class FallBackBody(ElementBase):

View file

@ -35,7 +35,7 @@ class TestReply(SlixTest):
""" """
<message xmlns="jabber:client"> <message xmlns="jabber:client">
<body>12345\nrealbody</body> <body>12345\nrealbody</body>
<fallback xmlns='urn:xmpp:feature-fallback:0' for='NS'> <fallback xmlns='urn:xmpp:fallback:0' for='NS'>
<body start="0" end="6" /> <body start="0" end="6" />
</fallback> </fallback>
</message> </message>
@ -54,8 +54,8 @@ class TestReply(SlixTest):
""" """
<message xmlns="jabber:client" type="normal"> <message xmlns="jabber:client" type="normal">
<body>> Anna wrote:\n> Hi, how are you?\nGreat</body> <body>> Anna wrote:\n> Hi, how are you?\nGreat</body>
<fallback xmlns="urn:xmpp:feature-fallback:0" for="urn:xmpp:reply:0"> <fallback xmlns="urn:xmpp:fallback:0" for="urn:xmpp:reply:0">
<body start='0' end='32' /> <body start='0' end='33' />
</fallback> </fallback>
</message> </message>
""" """

View file

@ -28,7 +28,7 @@ class TestReply(SlixTest):
<message id="other-id" from="from@from.com/res"> <message id="other-id" from="from@from.com/res">
<reply xmlns="urn:xmpp:reply:0" id="some-id" /> <reply xmlns="urn:xmpp:reply:0" id="some-id" />
<body>&gt; quoted\nsome-body</body> <body>&gt; quoted\nsome-body</body>
<fallback xmlns='urn:xmpp:feature-fallback:0' for='urn:xmpp:reply:0'> <fallback xmlns='urn:xmpp:fallback:0' for='urn:xmpp:reply:0'>
<body start="0" end="8" /> <body start="0" end="8" />
</fallback> </fallback>
</message> </message>