Add AddressBookRevokeAllSignatures method for revoking all signing keys of a contact
https://github.com/nosial/Socialbox-PHP/issues/73
This commit is contained in:
parent
86f18b577a
commit
66d2cd7907
3 changed files with 97 additions and 2 deletions
|
@ -432,6 +432,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a signing key from a contact in the database.
|
||||
*
|
||||
* @param string|ContactDatabaseRecord $contactUuid The unique identifier of the contact to remove the signing key from.
|
||||
* @param string $signatureUuid The UUID of the signing key to remove.
|
||||
* @return void
|
||||
* @throws DatabaseOperationException If the database query fails.
|
||||
*/
|
||||
public static function removeContactSigningKey(string|ContactDatabaseRecord $contactUuid, string $signatureUuid): void
|
||||
{
|
||||
if($contactUuid instanceof ContactDatabaseRecord)
|
||||
|
@ -452,6 +460,32 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all signing keys for a contact from the database.
|
||||
*
|
||||
* @param string|ContactDatabaseRecord $contactUuid The unique identifier of the contact to remove all signing keys from.
|
||||
* @return void
|
||||
* @throws DatabaseOperationException If the database query fails.
|
||||
*/
|
||||
public static function removeAllContactSigningKeys(string|ContactDatabaseRecord $contactUuid): void
|
||||
{
|
||||
if($contactUuid instanceof ContactDatabaseRecord)
|
||||
{
|
||||
$contactUuid = $contactUuid->getUuid();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$statement = Database::getConnection()->prepare('DELETE FROM contacts_known_keys WHERE contact_uuid=:contact_uuid');
|
||||
$statement->bindParam(':contact_uuid', $contactUuid);
|
||||
$statement->execute();
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
throw new DatabaseOperationException('Failed to remove all signing keys from a contact in the database', $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a signing key UUID exists for a contact in the database.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue