Skip to content

Commit

Permalink
Update version to 0.5.10.1 and enhance contact-seen mechanism
Browse files Browse the repository at this point in the history
Incremented version to 0.5.10.1 across setup.cfg, pyproject.toml, and __init__.py. Additionally, improved the contact management by marking contacts as seen when they have no last_seen timestamp and modified the __seen__ method to handle None values for time_seen more effectively.
  • Loading branch information
pnearing committed Sep 11, 2024
1 parent 0072298 commit a13d39f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "SignalCliAPi"
version = "0.5.10"
version = "0.5.10.1"
authors = [
{ name="Peter Nearing", email="[email protected]" }
]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = SignalCliApi
version = 0.5.10
version = 0.5.10.1
author = Peter Nearing
author_email = [email protected]
description = A python interface to the signal-cli found at https://github.com/AsamK/signal-cli
Expand Down
2 changes: 1 addition & 1 deletion src/signal_cli_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
File: __init__.py
Description: A python3 interface to signal-cli.
"""
__version__: str = '0.5.10'
__version__: str = '0.5.10.1'
__author__: str = 'Peter Nearing'
__email__: str = '[email protected]'

Expand Down
11 changes: 9 additions & 2 deletions src/signal_cli_api/signal_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ def __init__(self,
if self.devices is None:
self.devices = SignalDevices(sync_socket=self._sync_socket, account_id=self.get_id())

# Mark this contact as seen if none exists:
if self.last_seen is None:
self.__seen__()

# Validate that this is a valid contact:
if self.number is None and self.uuid is None:
raise RuntimeError("Invalid contact created, has no number and no uuid.")
Expand Down Expand Up @@ -432,16 +436,19 @@ def __parse_typing_message__(self, message) -> None:
############################
# Methods:
############################
def __seen__(self, time_seen: SignalTimestamp) -> None:
def __seen__(self, time_seen: SignalTimestamp = None) -> None:
"""
Update the last time this contact has been seen.
:param time_seen: SignalTimestamp: The time this contact was seen at.
:raises: TypeError: If time_seen is not a SignalTimestamp object.
"""
logger: logging.Logger = logging.getLogger(__name__ + '.' + self.__seen__.__name__)
if not isinstance(time_seen, SignalTimestamp):
if time_seen is not None and not isinstance(time_seen, SignalTimestamp):
logger.critical("Raising TypeError:")
__type_error__('time_seen', 'SignalTimestamp', time_seen)
if time_seen is None:
time_seen = SignalTimestamp(now=True)

if self.last_seen is not None:
self.last_seen = max(time_seen, self.last_seen)
else:
Expand Down

0 comments on commit a13d39f

Please sign in to comment.