implemented dual Nextcloud push registration with separate general and talk apptypes to ensure reliable Talk notification delivery; introduced stacked MessagingStyle notifications for chat threads with support for circular conversation avatars and disk caching
This commit is contained in:
@@ -39,17 +39,24 @@ class NextcloudPushApi {
|
||||
|
||||
NextcloudPushApi({http.Client? client}) : _client = client ?? http.Client();
|
||||
|
||||
/// Registers (or refreshes) this device. [devicePublicKeyPem] must be the
|
||||
/// 64-column SPKI PEM. [proxyServer] is the MarianumConnect push-proxy base
|
||||
/// URL (with trailing slash).
|
||||
/// Registers (or refreshes) a device subscription. [devicePublicKeyPem] must
|
||||
/// be the 64-column SPKI PEM. [proxyServer] is the MarianumConnect push-proxy
|
||||
/// base URL (with trailing slash).
|
||||
///
|
||||
/// [authorizationHeader] overrides the Basic auth (e.g. the Talk app
|
||||
/// password — NC binds the subscription to the authenticated session token).
|
||||
/// [userAgent] overrides the UA; a Talk-pattern UA makes NC classify the
|
||||
/// subscription as apptype `talk` and route Talk pushes to it.
|
||||
Future<NextcloudPushRegistration> register({
|
||||
required String pushTokenHash,
|
||||
required String devicePublicKeyPem,
|
||||
required String proxyServer,
|
||||
String? authorizationHeader,
|
||||
String? userAgent,
|
||||
}) async {
|
||||
final response = await _client.post(
|
||||
NextcloudOcs.uri(_path),
|
||||
headers: NextcloudOcs.headers(),
|
||||
headers: _headers(authorizationHeader, userAgent),
|
||||
body: {
|
||||
'pushTokenHash': pushTokenHash,
|
||||
'devicePublicKey': devicePublicKeyPem,
|
||||
@@ -76,13 +83,24 @@ class NextcloudPushApi {
|
||||
);
|
||||
}
|
||||
|
||||
/// Unregisters this device from Nextcloud push. Returns true when the server
|
||||
/// responded 202, meaning the proxy subscription should also be removed.
|
||||
Future<bool> unregister() async {
|
||||
/// Unregisters one device subscription — the DELETE is per session token, so
|
||||
/// each registration is removed with its own app password via
|
||||
/// [authorizationHeader]. Returns true when the server responded 202,
|
||||
/// meaning the proxy subscription should also be removed.
|
||||
Future<bool> unregister({String? authorizationHeader}) async {
|
||||
final response = await _client.delete(
|
||||
NextcloudOcs.uri(_path),
|
||||
headers: NextcloudOcs.headers(),
|
||||
headers: _headers(authorizationHeader, null),
|
||||
);
|
||||
return response.statusCode == 202;
|
||||
}
|
||||
|
||||
Map<String, String> _headers(
|
||||
String? authorizationHeader,
|
||||
String? userAgent,
|
||||
) => {
|
||||
...NextcloudOcs.headers(),
|
||||
'Authorization': ?authorizationHeader,
|
||||
'User-Agent': ?userAgent,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user