massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
This commit is contained in:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -70,13 +70,13 @@ class XEP_0424(object):
|
|||
def __init__(self, host):
|
||||
log.info(_("XEP-0424 (Message Retraction) plugin initialization"))
|
||||
self.host = host
|
||||
host.memory.updateParams(PARAMS)
|
||||
host.memory.update_params(PARAMS)
|
||||
self._h = host.plugins["XEP-0334"]
|
||||
self._f = host.plugins["XEP-0422"]
|
||||
host.registerNamespace("message-retract", NS_MESSAGE_RETRACT)
|
||||
host.trigger.add("messageReceived", self._messageReceivedTrigger, 100)
|
||||
host.bridge.addMethod(
|
||||
"messageRetract",
|
||||
host.register_namespace("message-retract", NS_MESSAGE_RETRACT)
|
||||
host.trigger.add("messageReceived", self._message_received_trigger, 100)
|
||||
host.bridge.add_method(
|
||||
"message_retract",
|
||||
".plugin",
|
||||
in_sign="ss",
|
||||
out_sign="",
|
||||
|
|
@ -84,16 +84,16 @@ class XEP_0424(object):
|
|||
async_=True,
|
||||
)
|
||||
|
||||
def getHandler(self, __):
|
||||
def get_handler(self, __):
|
||||
return XEP_0424_handler()
|
||||
|
||||
def _retract(self, message_id: str, profile: str) -> None:
|
||||
client = self.host.getClient(profile)
|
||||
client = self.host.get_client(profile)
|
||||
return defer.ensureDeferred(
|
||||
self.retract(client, message_id)
|
||||
)
|
||||
|
||||
def retractByOriginId(
|
||||
def retract_by_origin_id(
|
||||
self,
|
||||
client: SatXMPPEntity,
|
||||
dest_jid: jid.JID,
|
||||
|
|
@ -109,17 +109,17 @@ class XEP_0424(object):
|
|||
message_elt = domish.Element((None, "message"))
|
||||
message_elt["from"] = client.jid.full()
|
||||
message_elt["to"] = dest_jid.full()
|
||||
apply_to_elt = self._f.applyToElt(message_elt, origin_id)
|
||||
apply_to_elt = self._f.apply_to_elt(message_elt, origin_id)
|
||||
apply_to_elt.addElement((NS_MESSAGE_RETRACT, "retract"))
|
||||
self.host.plugins["XEP-0428"].addFallbackElt(
|
||||
self.host.plugins["XEP-0428"].add_fallback_elt(
|
||||
message_elt,
|
||||
"[A message retraction has been requested, but your client doesn't support "
|
||||
"it]"
|
||||
)
|
||||
self._h.addHintElements(message_elt, [self._h.HINT_STORE])
|
||||
self._h.add_hint_elements(message_elt, [self._h.HINT_STORE])
|
||||
client.send(message_elt)
|
||||
|
||||
async def retractByHistory(
|
||||
async def retract_by_history(
|
||||
self,
|
||||
client: SatXMPPEntity,
|
||||
history: History
|
||||
|
|
@ -138,8 +138,8 @@ class XEP_0424(object):
|
|||
"client is probably not supporting message retraction."
|
||||
)
|
||||
else:
|
||||
self.retractByOriginId(client, history.dest_jid, origin_id)
|
||||
await self.retractDBHistory(client, history)
|
||||
self.retract_by_origin_id(client, history.dest_jid, origin_id)
|
||||
await self.retract_db_history(client, history)
|
||||
|
||||
async def retract(
|
||||
self,
|
||||
|
|
@ -163,9 +163,9 @@ class XEP_0424(object):
|
|||
raise exceptions.NotFound(
|
||||
f"message to retract not found in database ({message_id})"
|
||||
)
|
||||
await self.retractByHistory(client, history)
|
||||
await self.retract_by_history(client, history)
|
||||
|
||||
async def retractDBHistory(self, client, history: History) -> None:
|
||||
async def retract_db_history(self, client, history: History) -> None:
|
||||
"""Mark an history instance in database as retracted
|
||||
|
||||
@param history: history instance
|
||||
|
|
@ -176,7 +176,7 @@ class XEP_0424(object):
|
|||
# we assign a new object to be sure to trigger an update
|
||||
history.extra = deepcopy(history.extra) if history.extra else {}
|
||||
history.extra["retracted"] = True
|
||||
keep_history = self.host.memory.getParamA(
|
||||
keep_history = self.host.memory.param_get_a(
|
||||
NAME, CATEGORY, profile_key=client.profile
|
||||
)
|
||||
old_version: Dict[str, Any] = {
|
||||
|
|
@ -194,13 +194,13 @@ class XEP_0424(object):
|
|||
session_add=[history]
|
||||
)
|
||||
|
||||
async def _messageReceivedTrigger(
|
||||
async def _message_received_trigger(
|
||||
self,
|
||||
client: SatXMPPEntity,
|
||||
message_elt: domish.Element,
|
||||
post_treat: defer.Deferred
|
||||
) -> bool:
|
||||
fastened_elts = await self._f.getFastenedElts(client, message_elt)
|
||||
fastened_elts = await self._f.get_fastened_elts(client, message_elt)
|
||||
if fastened_elts is None:
|
||||
return True
|
||||
for elt in fastened_elts.elements:
|
||||
|
|
@ -218,7 +218,7 @@ class XEP_0424(object):
|
|||
break
|
||||
else:
|
||||
return True
|
||||
if not await self.host.trigger.asyncPoint(
|
||||
if not await self.host.trigger.async_point(
|
||||
"XEP-0424_retractReceived", client, message_elt, elt, fastened_elts
|
||||
):
|
||||
return False
|
||||
|
|
@ -230,7 +230,7 @@ class XEP_0424(object):
|
|||
)
|
||||
return False
|
||||
log.info(f"[{client.profile}] retracting message {fastened_elts.id!r}")
|
||||
await self.retractDBHistory(client, fastened_elts.history)
|
||||
await self.retract_db_history(client, fastened_elts.history)
|
||||
# TODO: send bridge signal
|
||||
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in a new issue