This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for playing album on cast.ente.io (#1694)
- Loading branch information
Showing
6 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import "package:dio/dio.dart"; | ||
|
||
class CastGateway { | ||
final Dio _enteDio; | ||
|
||
CastGateway(this._enteDio); | ||
|
||
Future<String?> getPublicKey(String deviceCode) async { | ||
try { | ||
final response = await _enteDio.get( | ||
"/cast/device-info/$deviceCode", | ||
); | ||
return response.data["publicKey"]; | ||
} catch (e) { | ||
if (e is DioError && | ||
e.response != null && | ||
e.response!.statusCode == 404) { | ||
return null; | ||
} | ||
rethrow; | ||
} | ||
} | ||
|
||
Future<void> publishCastPayload( | ||
String code, | ||
String castPayload, | ||
int collectionID, | ||
String castToken, | ||
) { | ||
return _enteDio.post( | ||
"/cast/cast-data/", | ||
data: { | ||
"deviceCode": code, | ||
"encPayload": castPayload, | ||
"collectionID": collectionID, | ||
"castToken": castToken, | ||
}, | ||
); | ||
} | ||
|
||
Future<void> revokeAllTokens() async { | ||
try { | ||
await _enteDio.delete( | ||
"/cast/revoke-all-tokens/", | ||
); | ||
} catch (e) { | ||
// swallow error | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters