kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add more fine-grained privacy processing for direct messages and preserving settings on comments
rodzic
46ed40920b
commit
1d65ba2604
|
@ -843,7 +843,7 @@ class StatusesClient extends FriendicaClient {
|
|||
if (spoilerText.isNotEmpty) 'spoiler_text': spoilerText,
|
||||
if (inReplyToId.isNotEmpty) 'in_reply_to_id': inReplyToId,
|
||||
if (mediaIds.isNotEmpty) 'media_ids': mediaIds,
|
||||
'visibility': visibility.toCreateStatusValue(),
|
||||
'visibility': visibility.toCreateStatusValue(inReplyToId.isNotEmpty),
|
||||
'friendica': {
|
||||
'title': '',
|
||||
},
|
||||
|
|
|
@ -71,9 +71,33 @@ extension TimelineEntryMastodonExtensions on TimelineEntry {
|
|||
: 0;
|
||||
|
||||
final youReshared = json['reblogged'] ?? false;
|
||||
final visibility = ['public', 'unlisted'].contains(json['visibility'])
|
||||
? Visibility.public()
|
||||
: Visibility.private();
|
||||
late final Visibility visibility;
|
||||
final visibilityString = json['visibility'];
|
||||
if (visibilityString == 'public') {
|
||||
visibility = Visibility.public();
|
||||
} else if (visibilityString == 'private') {
|
||||
final allowedUserIds =
|
||||
json['friendica']?['visibility']?['allow_cid'] as List<dynamic>? ??
|
||||
[];
|
||||
final excludedUserIds =
|
||||
json['friendica']?['visibility']?['deny_cid'] as List<dynamic>? ?? [];
|
||||
final allowedCircleIds =
|
||||
json['friendica']?['visibility']?['allow_gid'] as List<dynamic>? ??
|
||||
[];
|
||||
final excludedCircleIds =
|
||||
json['friendica']?['visibility']?['deny_gid'] as List<dynamic>? ?? [];
|
||||
visibility = Visibility(
|
||||
type: VisibilityType.private,
|
||||
allowedUserIds: allowedUserIds.map((e) => e.toString()).toList(),
|
||||
excludedUserIds: excludedUserIds.map((e) => e.toString()).toList(),
|
||||
allowedCircleIds: allowedCircleIds.map((e) => e.toString()).toList(),
|
||||
excludedCircleIds: excludedCircleIds.map((e) => e.toString()).toList(),
|
||||
);
|
||||
} else if (visibilityString == 'unlisted') {
|
||||
visibility = Visibility.private();
|
||||
} else {
|
||||
visibility = Visibility.private();
|
||||
}
|
||||
|
||||
const title = '';
|
||||
final body = json['content'] ?? '';
|
||||
|
|
|
@ -3,20 +3,34 @@ import 'package:relatica/models/circle_data.dart';
|
|||
import '../../models/visibility.dart';
|
||||
|
||||
extension VisibilityMastodonExtensions on Visibility {
|
||||
String toCreateStatusValue() {
|
||||
String toCreateStatusValue(bool onComment) {
|
||||
if (type == VisibilityType.public) {
|
||||
return 'public';
|
||||
}
|
||||
|
||||
if (hasDetails) {
|
||||
final circleId = allowedCircleIds.first;
|
||||
if (!onComment && hasDetails) {
|
||||
final circleId =
|
||||
allowedCircleIds.firstOrNull ?? allowedUserIds.firstOrNull;
|
||||
if (circleId == CircleData.followersPseudoCircle.id) {
|
||||
return 'private';
|
||||
}
|
||||
|
||||
return circleId;
|
||||
return circleId ?? 'private';
|
||||
}
|
||||
|
||||
if (onComment && !hasDetails && type == VisibilityType.private) {
|
||||
return 'direct';
|
||||
}
|
||||
|
||||
return 'private';
|
||||
}
|
||||
|
||||
Map<String, dynamic> friendicaExtensionVisibilityJson() {
|
||||
return {
|
||||
"allow_cid": allowedUserIds,
|
||||
"deny_cid": excludedUserIds,
|
||||
"allow_gid": allowedCircleIds,
|
||||
"deny_gid": excludedCircleIds,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue