kopia lustrzana https://gitlab.com/mysocialportal/relatica
Change Profile EP call to use Mastodon so can do some logging into Mastodon servers
rodzic
7365c4ad43
commit
46387e5a16
|
@ -19,7 +19,6 @@ import '../models/image_entry.dart';
|
|||
import '../models/media_attachment_uploads/image_types_enum.dart';
|
||||
import '../models/timeline_entry.dart';
|
||||
import '../models/user_notification.dart';
|
||||
import '../serializers/friendica/connection_friendica_extensions.dart';
|
||||
import '../serializers/friendica/direct_message_friendica_extensions.dart';
|
||||
import '../serializers/friendica/gallery_data_friendica_extensions.dart';
|
||||
import '../serializers/friendica/image_entry_friendica_extensions.dart';
|
||||
|
@ -549,10 +548,16 @@ class ProfileClient extends FriendicaClient {
|
|||
|
||||
FutureResult<Connection, ExecError> getMyProfile() async {
|
||||
_logger.finest(() => 'Getting logged in user profile');
|
||||
final request = Uri.parse('https://$serverName/api/friendica/profile/show');
|
||||
return (await _getApiRequest(request)).mapValue((json) =>
|
||||
ConnectionFriendicaExtensions.fromJson(json['friendica_owner'])
|
||||
.copy(status: ConnectionStatus.you, network: 'friendica'));
|
||||
final request =
|
||||
Uri.parse('https://$serverName/api/v1/accounts/verify_credentials');
|
||||
return (await _getApiRequest(request))
|
||||
.mapValue((json) => ConnectionMastodonExtensions.fromJson(
|
||||
json,
|
||||
defaultServerName: serverName,
|
||||
).copy(
|
||||
status: ConnectionStatus.you,
|
||||
network: 'friendica',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ import '../../models/connection.dart';
|
|||
import '../../services/auth_service.dart';
|
||||
|
||||
extension ConnectionMastodonExtensions on Connection {
|
||||
static Connection fromJson(Map<String, dynamic> json) {
|
||||
static Connection fromJson(Map<String, dynamic> json,
|
||||
{String defaultServerName = ''}) {
|
||||
final name = json['display_name'] ?? '';
|
||||
final id = json['id']?.toString() ?? '';
|
||||
final profileUrl = Uri.parse(json['url'] ?? '');
|
||||
|
@ -20,7 +21,9 @@ extension ConnectionMastodonExtensions on Connection {
|
|||
if (handleFromJson.contains('@')) {
|
||||
handle = handleFromJson;
|
||||
} else {
|
||||
final server = getIt<AccountsService>().currentProfile.serverName;
|
||||
final server = defaultServerName.isNotEmpty
|
||||
? defaultServerName
|
||||
: getIt<AccountsService>().currentProfile.serverName;
|
||||
handle = '$handleFromJson@$server';
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue