Compare commits

...

2 Commits

Author SHA1 Message Date
4499d4ec8e 🐛 Fix serval path breaking changes 2025-07-19 02:50:24 +08:00
3a4faac8cb 🐛 Dozens of bug fixes 2025-07-18 18:57:16 +08:00
13 changed files with 58 additions and 43 deletions

View File

@@ -26,6 +26,7 @@ sealed class WebSocketPacket with _$WebSocketPacket {
const factory WebSocketPacket({
required String type,
required Map<String, dynamic>? data,
String? endpoint,
String? errorMessage,
}) = _WebSocketPacket;

View File

@@ -379,7 +379,7 @@ as String,
/// @nodoc
mixin _$WebSocketPacket implements DiagnosticableTreeMixin {
String get type; Map<String, dynamic>? get data; String? get errorMessage;
String get type; Map<String, dynamic>? get data; String? get endpoint; String? get errorMessage;
/// Create a copy of WebSocketPacket
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -393,21 +393,21 @@ $WebSocketPacketCopyWith<WebSocketPacket> get copyWith => _$WebSocketPacketCopyW
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'WebSocketPacket'))
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('errorMessage', errorMessage));
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('endpoint', endpoint))..add(DiagnosticsProperty('errorMessage', errorMessage));
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.endpoint, endpoint) || other.endpoint == endpoint)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(data),errorMessage);
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(data),endpoint,errorMessage);
@override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
return 'WebSocketPacket(type: $type, data: $data, errorMessage: $errorMessage)';
return 'WebSocketPacket(type: $type, data: $data, endpoint: $endpoint, errorMessage: $errorMessage)';
}
@@ -418,7 +418,7 @@ abstract mixin class $WebSocketPacketCopyWith<$Res> {
factory $WebSocketPacketCopyWith(WebSocketPacket value, $Res Function(WebSocketPacket) _then) = _$WebSocketPacketCopyWithImpl;
@useResult
$Res call({
String type, Map<String, dynamic>? data, String? errorMessage
String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage
});
@@ -435,11 +435,12 @@ class _$WebSocketPacketCopyWithImpl<$Res>
/// Create a copy of WebSocketPacket
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? type = null,Object? data = freezed,Object? errorMessage = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? type = null,Object? data = freezed,Object? endpoint = freezed,Object? errorMessage = freezed,}) {
return _then(_self.copyWith(
type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,endpoint: freezed == endpoint ? _self.endpoint : endpoint // ignore: cast_nullable_to_non_nullable
as String?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
));
}
@@ -522,10 +523,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _WebSocketPacket() when $default != null:
return $default(_that.type,_that.data,_that.errorMessage);case _:
return $default(_that.type,_that.data,_that.endpoint,_that.errorMessage);case _:
return orElse();
}
@@ -543,10 +544,10 @@ return $default(_that.type,_that.data,_that.errorMessage);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage) $default,) {final _that = this;
switch (_that) {
case _WebSocketPacket():
return $default(_that.type,_that.data,_that.errorMessage);}
return $default(_that.type,_that.data,_that.endpoint,_that.errorMessage);}
}
/// A variant of `when` that fallback to returning `null`
///
@@ -560,10 +561,10 @@ return $default(_that.type,_that.data,_that.errorMessage);}
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String type, Map<String, dynamic>? data, String? errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage)? $default,) {final _that = this;
switch (_that) {
case _WebSocketPacket() when $default != null:
return $default(_that.type,_that.data,_that.errorMessage);case _:
return $default(_that.type,_that.data,_that.endpoint,_that.errorMessage);case _:
return null;
}
@@ -575,7 +576,7 @@ return $default(_that.type,_that.data,_that.errorMessage);case _:
@JsonSerializable()
class _WebSocketPacket with DiagnosticableTreeMixin implements WebSocketPacket {
const _WebSocketPacket({required this.type, required final Map<String, dynamic>? data, this.errorMessage}): _data = data;
const _WebSocketPacket({required this.type, required final Map<String, dynamic>? data, this.endpoint, this.errorMessage}): _data = data;
factory _WebSocketPacket.fromJson(Map<String, dynamic> json) => _$WebSocketPacketFromJson(json);
@override final String type;
@@ -588,6 +589,7 @@ class _WebSocketPacket with DiagnosticableTreeMixin implements WebSocketPacket {
return EqualUnmodifiableMapView(value);
}
@override final String? endpoint;
@override final String? errorMessage;
/// Create a copy of WebSocketPacket
@@ -604,21 +606,21 @@ Map<String, dynamic> toJson() {
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'WebSocketPacket'))
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('errorMessage', errorMessage));
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('endpoint', endpoint))..add(DiagnosticsProperty('errorMessage', errorMessage));
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._data, _data)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._data, _data)&&(identical(other.endpoint, endpoint) || other.endpoint == endpoint)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(_data),errorMessage);
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(_data),endpoint,errorMessage);
@override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
return 'WebSocketPacket(type: $type, data: $data, errorMessage: $errorMessage)';
return 'WebSocketPacket(type: $type, data: $data, endpoint: $endpoint, errorMessage: $errorMessage)';
}
@@ -629,7 +631,7 @@ abstract mixin class _$WebSocketPacketCopyWith<$Res> implements $WebSocketPacket
factory _$WebSocketPacketCopyWith(_WebSocketPacket value, $Res Function(_WebSocketPacket) _then) = __$WebSocketPacketCopyWithImpl;
@override @useResult
$Res call({
String type, Map<String, dynamic>? data, String? errorMessage
String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage
});
@@ -646,11 +648,12 @@ class __$WebSocketPacketCopyWithImpl<$Res>
/// Create a copy of WebSocketPacket
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? type = null,Object? data = freezed,Object? errorMessage = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? type = null,Object? data = freezed,Object? endpoint = freezed,Object? errorMessage = freezed,}) {
return _then(_WebSocketPacket(
type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,data: freezed == data ? _self._data : data // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,endpoint: freezed == endpoint ? _self.endpoint : endpoint // ignore: cast_nullable_to_non_nullable
as String?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
));
}

View File

@@ -10,6 +10,7 @@ _WebSocketPacket _$WebSocketPacketFromJson(Map<String, dynamic> json) =>
_WebSocketPacket(
type: json['type'] as String,
data: json['data'] as Map<String, dynamic>?,
endpoint: json['endpoint'] as String?,
errorMessage: json['error_message'] as String?,
);
@@ -17,5 +18,6 @@ Map<String, dynamic> _$WebSocketPacketToJson(_WebSocketPacket instance) =>
<String, dynamic>{
'type': instance.type,
'data': instance.data,
'endpoint': instance.endpoint,
'error_message': instance.errorMessage,
};

View File

@@ -77,7 +77,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
}
final client = ref.watch(apiClientProvider);
await client.patch(
'/accounts/me/profile',
'/id/accounts/me/profile',
data: {'${position}_id': cloudFile.id},
);
final userNotifier = ref.read(userInfoProvider.notifier);
@@ -102,7 +102,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
try {
final client = ref.watch(apiClientProvider);
await client.patch(
'/accounts/me',
'/id/accounts/me',
data: {
'name': usernameController.text,
'nick': nicknameController.text,
@@ -154,7 +154,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
try {
final client = ref.watch(apiClientProvider);
await client.patch(
'/accounts/me/profile',
'/id/accounts/me/profile',
data: {
'bio': bioController.text,
'first_name': firstNameController.text,

View File

@@ -6,7 +6,7 @@ part of 'captcha.config.dart';
// RiverpodGenerator
// **************************************************************************
String _$captchaUrlHash() => r'627caa2f2eb020a28a4b138122fe8e99915185f9';
String _$captchaUrlHash() => r'bbed0d18272dd205069642b3c6583ea2eef735d1';
/// See also [captchaUrl].
@ProviderFor(captchaUrl)

View File

@@ -376,7 +376,11 @@ class ChatRoomScreen extends HookConsumerWidget {
final wsState = ref.read(websocketStateProvider.notifier);
wsState.sendMessage(
jsonEncode(
WebSocketPacket(type: 'messages.read', data: {'chat_room_id': id}),
WebSocketPacket(
type: 'messages.read',
data: {'chat_room_id': id},
endpoint: 'DysonNetwork.Sphere',
),
),
);
}
@@ -393,7 +397,11 @@ class ChatRoomScreen extends HookConsumerWidget {
final wsState = ref.read(websocketStateProvider.notifier);
wsState.sendMessage(
jsonEncode(
WebSocketPacket(type: 'messages.typing', data: {'chat_room_id': id}),
WebSocketPacket(
type: 'messages.typing',
data: {'chat_room_id': id},
endpoint: 'DysonNetwork.Sphere',
),
),
);

View File

@@ -160,11 +160,11 @@ class EditPublisherScreen extends HookConsumerWidget {
try {
final client = ref.watch(apiClientProvider);
final resp = await client.request(
name == null
'/sphere${name == null
? currentRealm.value == null
? '/publishers/individual'
: '/publishers/organization/${currentRealm.value!.slug}'
: '/publishers/$name',
: '/publishers/$name'}',
data: {
'name': nameController.text,
'nick': nickController.text,

View File

@@ -175,8 +175,8 @@ Completer<SnCloudFile?> _processUpload(
final client = TusClient(file);
client
.upload(
uri: Uri.parse('$baseUrl/files/tus'),
headers: {'Authorization': 'Bearer $atk'},
uri: Uri.parse('$baseUrl/drive/tus'),
headers: {'Authorization': 'AtField $atk'},
metadata: metadata,
onComplete: (lastResponse) {
final resp = jsonDecode(lastResponse!.headers['x-fileinfo']!);

View File

@@ -110,7 +110,7 @@ Future<void> _putTokenToRemote(
int provider,
) async {
await apiClient.put(
"/notifications/subscription",
"/pusher/notifications/subscription",
data: {"provider": provider, "device_token": token},
);
}

View File

@@ -6,7 +6,7 @@ part of 'account_picker.dart';
// RiverpodGenerator
// **************************************************************************
String _$searchAccountsHash() => r'4923cd06876d04515d95d3c58ee3ea9e05c58e4a';
String _$searchAccountsHash() => r'fa3b8b7d51e14cf40d4116ba0ff0b6955fa0ff54';
/// Copied from Dart SDK
class _SystemHash {

View File

@@ -38,7 +38,7 @@ class CloudFileList extends HookConsumerWidget {
double calculateAspectRatio() {
double total = 0;
for (var ratio in files.map((e) => e.fileMeta?['ratio'] ?? 1)) {
total += ratio;
total += double.parse(ratio);
}
if (total == 0) return 1;
return total / files.length;

View File

@@ -25,9 +25,9 @@ class CloudFileWidget extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final serverUrl = ref.watch(serverUrlProvider);
final uri = '$serverUrl/api/files/${item.id}';
final uri = '$serverUrl/drive/files/${item.id}';
var ratio = (item.fileMeta?['ratio'] ?? 1).toDouble();
var ratio = double.parse(item.fileMeta?['ratio'] ?? 1);
if (ratio == 0) ratio = 1.0;
final content = switch (item.mimeType?.split('/').firstOrNull) {
"image" => AspectRatio(
@@ -70,7 +70,7 @@ class CloudImageWidget extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final serverUrl = ref.watch(serverUrlProvider);
final uri = '$serverUrl/api/files/${file?.id ?? fileId}';
final uri = '$serverUrl/drive/files/${file?.id ?? fileId}';
return AspectRatio(
aspectRatio: aspectRatio,
@@ -86,7 +86,7 @@ class CloudImageWidget extends ConsumerWidget {
required String serverUrl,
bool original = false,
}) {
final uri = '$serverUrl/api/files/$fileId?original=$original';
final uri = '$serverUrl/drive/files/$fileId?original=$original';
return CachedNetworkImageProvider(uri);
}
}
@@ -109,7 +109,7 @@ class ProfilePictureWidget extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final serverUrl = ref.watch(serverUrlProvider);
final uri = '$serverUrl/api/files/${file?.id ?? fileId}';
final uri = '$serverUrl/drive/files/${file?.id ?? fileId}';
return ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(radius)),
@@ -302,7 +302,7 @@ class SplitAvatarWidget extends ConsumerWidget {
}
final serverUrl = ref.watch(serverUrlProvider);
final uri = '$serverUrl/api/files/$fileId';
final uri = '$serverUrl/drive/files/$fileId';
return SizedBox(
width: radius,

View File

@@ -467,7 +467,7 @@ class ComposeLogic {
final attachment = state.attachments.value[index];
if (attachment.isOnCloud) {
final client = ref.watch(apiClientProvider);
await client.delete('/files/${attachment.data.id}');
await client.delete('/drive/files/${attachment.data.id}');
}
final clone = List.of(state.attachments.value);
clone.removeAt(index);
@@ -530,7 +530,8 @@ class ComposeLogic {
// Prepare API request
final client = ref.watch(apiClientProvider);
final isNewPost = originalPost == null;
final endpoint = isNewPost ? '/posts' : '/posts/${originalPost.id}';
final endpoint =
'/sphere${isNewPost ? '/posts' : '/posts/${originalPost.id}'}';
// Create request payload
final payload = {