forked from LeineLab-Public/lab-signal-bot
SignalAPI: return updated group members in update_group_members()
This commit is contained in:
parent
6870d274b5
commit
89d2582bf7
@ -61,6 +61,10 @@ class CreateGroupRequest(BaseModel):
|
|||||||
class CreateGroupResponse(BaseModel):
|
class CreateGroupResponse(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
|
|
||||||
|
class UpdateGroupResult(BaseModel):
|
||||||
|
members_added: List[str]
|
||||||
|
members_removed: List[str]
|
||||||
|
|
||||||
def test_reaction_message():
|
def test_reaction_message():
|
||||||
data = """{
|
data = """{
|
||||||
"envelope": {
|
"envelope": {
|
||||||
|
4
main.py
4
main.py
@ -93,7 +93,7 @@ class SignalAPI:
|
|||||||
print("Failed to remove group members")
|
print("Failed to remove group members")
|
||||||
print(r.json())
|
print(r.json())
|
||||||
|
|
||||||
def update_group_members(self, group_id: str, other_members: List[str]) -> Result[None, str]:
|
def update_group_members(self, group_id: str, other_members: List[str]) -> Result[UpdateGroupResult, str]:
|
||||||
group = self.get_group(group_id)
|
group = self.get_group(group_id)
|
||||||
if is_err(group):
|
if is_err(group):
|
||||||
return Err(group.unwrap_err())
|
return Err(group.unwrap_err())
|
||||||
@ -121,7 +121,7 @@ class SignalAPI:
|
|||||||
if remove_result.is_err():
|
if remove_result.is_err():
|
||||||
return Err(remove_result.unwrap_err())
|
return Err(remove_result.unwrap_err())
|
||||||
|
|
||||||
return Ok(None)
|
return Ok(UpdateGroupResult(members_added=members_to_add, members_removed=members_to_remove))
|
||||||
|
|
||||||
def get_identities(self) -> Result[List[IdentityEntry], str]:
|
def get_identities(self) -> Result[List[IdentityEntry], str]:
|
||||||
r = requests.get(f"{self.apiurl}/v1/identities/{self.number}")
|
r = requests.get(f"{self.apiurl}/v1/identities/{self.number}")
|
||||||
|
Loading…
Reference in New Issue
Block a user