diff options
author | Joas Schilling <coding@schilljs.com> | 2021-12-03 17:17:53 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-02-17 18:31:00 +0300 |
commit | 4eb1f73ca1170329d80a6f040461fb7ac7be4ecc (patch) | |
tree | 9f93aaabf76f047ad8caa9ce3babd81d1687c962 /lib/Model | |
parent | 55121e46170af29d752eece2b99cc72bb8b6f1e2 (diff) |
Add an API endpoint to get all invites
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Model')
-rw-r--r-- | lib/Model/InvitationMapper.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Model/InvitationMapper.php b/lib/Model/InvitationMapper.php index f54cbafd8..01f288678 100644 --- a/lib/Model/InvitationMapper.php +++ b/lib/Model/InvitationMapper.php @@ -32,6 +32,7 @@ use OCP\AppFramework\Db\QBMapper; use OCP\DB\Exception as DBException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; +use OCP\IUser; /** * Class InvitationMapper @@ -78,6 +79,21 @@ class InvitationMapper extends QBMapper { } /** + * @param IUser $user + * @return Invitation[] + * @throws DBException + */ + public function getInvitationsForUser(IUser $user): array { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user->getUID()))); + + return $this->findEntities($qb); + } + + /** * @throws DBException */ public function countInvitationsForRoom(Room $room): int { |