getLinkIfAllowed

@Query(value = "SELECT l.* FROM " + LINKS_KEY + " AS l WHERE l." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND l." + LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY + " UNION " + "SELECT l.* FROM " + LINKS_KEY + " AS l INNER JOIN " + COLLECTIONS_LINKS_TABLE + " ON " + COLLECTIONS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY + " = l." + LINK_IDENTIFIER_KEY + " INNER JOIN " + COLLECTIONS_TEAMS_TABLE + " ON " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " = " + COLLECTIONS_LINKS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " INNER JOIN " + MEMBERS_KEY + " ON " + COLLECTIONS_TEAMS_TABLE + "." + TEAM_IDENTIFIER_KEY + " = " + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY + " WHERE " + MEMBERS_KEY + "." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND l." + LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY + " AND dtype='" + LINK_KEY + "'", nativeQuery = true)
abstract fun getLinkIfAllowed(@Param(value = "user_id") userId: String, @Param(value = "link_id") linkId: String): RefyLink

Method to execute the query to get a link if the owner is authorized

Return

the link if the user is authorized as RefyLink

Parameters

userId

: the identifier of the user

linkId

: the link identifier