updated project linter-rules and enforced them
This commit is contained in:
@ -11,7 +11,7 @@ class GetChat extends TalkApi<GetChatResponse> {
|
||||
String chatToken;
|
||||
|
||||
GetChatParams params;
|
||||
GetChat(this.chatToken, this.params) : super("v1/chat/$chatToken", null, getParameters: params.toJson());
|
||||
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -9,7 +9,7 @@ class GetChatCache extends RequestCache<GetChatResponse> {
|
||||
String chatToken;
|
||||
|
||||
GetChatCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
|
||||
start("MarianumMobile", "nc-chat-$chatToken");
|
||||
start('MarianumMobile', 'nc-chat-$chatToken');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -61,21 +61,21 @@ class GetChatResponseObject {
|
||||
|
||||
static GetChatResponseObject getDateDummy(int timestamp) {
|
||||
DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: "dd.MM.yyyy"));
|
||||
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: 'dd.MM.yyyy'));
|
||||
}
|
||||
|
||||
static GetChatResponseObject getTextDummy(String text) {
|
||||
return GetChatResponseObject(
|
||||
0,
|
||||
"",
|
||||
'',
|
||||
GetRoomResponseObjectMessageActorType.user,
|
||||
"",
|
||||
"",
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
"",
|
||||
'',
|
||||
GetRoomResponseObjectMessageType.system,
|
||||
false,
|
||||
"",
|
||||
'',
|
||||
text,
|
||||
null,
|
||||
null,
|
||||
@ -113,10 +113,10 @@ class RichObjectString {
|
||||
}
|
||||
|
||||
enum RichObjectStringObjectType {
|
||||
@JsonValue("user") user,
|
||||
@JsonValue("group") group,
|
||||
@JsonValue("file") file,
|
||||
@JsonValue("guest") guest,
|
||||
@JsonValue("highlight") highlight,
|
||||
@JsonValue("talk-poll") talkPoll,
|
||||
@JsonValue('user') user,
|
||||
@JsonValue('group') group,
|
||||
@JsonValue('file') file,
|
||||
@JsonValue('guest') guest,
|
||||
@JsonValue('highlight') highlight,
|
||||
@JsonValue('talk-poll') talkPoll,
|
||||
}
|
@ -6,7 +6,7 @@ class RichObjectStringProcessor {
|
||||
if(data == null) return message;
|
||||
|
||||
data.forEach((key, value) {
|
||||
message = message.replaceAll(RegExp("{$key}"), value.name);
|
||||
message = message.replaceAll(RegExp('{$key}'), value.name);
|
||||
});
|
||||
|
||||
return message;
|
||||
|
@ -7,7 +7,7 @@ import 'createRoomParams.dart';
|
||||
class CreateRoom extends TalkApi {
|
||||
CreateRoomParams params;
|
||||
|
||||
CreateRoom(this.params) : super("v4/room", params);
|
||||
CreateRoom(this.params) : super('v4/room', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -7,7 +7,7 @@ import '../talkApi.dart';
|
||||
class DeleteMessage extends TalkApi {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
DeleteMessage(this.chatToken, this.messageId) : super("v1/chat/$chatToken/$messageId", null);
|
||||
DeleteMessage(this.chatToken, this.messageId) : super('v1/chat/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ import 'deleteReactMessageParams.dart';
|
||||
class DeleteReactMessage extends TalkApi {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super("v1/reaction/$chatToken/$messageId", params);
|
||||
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -7,7 +7,7 @@ import 'getParticipantsResponse.dart';
|
||||
|
||||
class GetParticipants extends TalkApi<GetParticipantsResponse> {
|
||||
String token;
|
||||
GetParticipants(this.token) : super("v4/room/$token/participants", null);
|
||||
GetParticipants(this.token) : super('v4/room/$token/participants', null);
|
||||
|
||||
@override
|
||||
GetParticipantsResponse assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ class GetParticipantsCache extends RequestCache<GetParticipantsResponse> {
|
||||
String chatToken;
|
||||
|
||||
GetParticipantsCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
|
||||
start("MarianumMobile", "nc-chat-participants-$chatToken");
|
||||
start('MarianumMobile', 'nc-chat-participants-$chatToken');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -10,7 +10,7 @@ import 'getReactionsResponse.dart';
|
||||
class GetReactions extends TalkApi<GetReactionsResponse> {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
GetReactions({required this.chatToken, required this.messageId}) : super("v1/reaction/$chatToken/$messageId", null);
|
||||
GetReactions({required this.chatToken, required this.messageId}) : super('v1/reaction/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -28,6 +28,6 @@ class GetReactionsResponseObject {
|
||||
}
|
||||
|
||||
enum GetReactionsResponseObjectActorType {
|
||||
@JsonValue("guests") guests,
|
||||
@JsonValue("users") users,
|
||||
@JsonValue('guests') guests,
|
||||
@JsonValue('users') users,
|
||||
}
|
@ -6,7 +6,7 @@ import '../talkApi.dart';
|
||||
class LeaveRoom extends TalkApi {
|
||||
String chatToken;
|
||||
|
||||
LeaveRoom(this.chatToken) : super("v4/room/$chatToken/participants/self", null);
|
||||
LeaveRoom(this.chatToken) : super('v4/room/$chatToken/participants/self', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ import 'reactMessageParams.dart';
|
||||
class ReactMessage extends TalkApi {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super("v1/reaction/$chatToken/$messageId", params);
|
||||
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -9,7 +9,7 @@ import 'getRoomResponse.dart';
|
||||
|
||||
class GetRoom extends TalkApi<GetRoomResponse> {
|
||||
GetRoomParams params;
|
||||
GetRoom(this.params) : super("v4/room", null, getParameters: params.toJson());
|
||||
GetRoom(this.params) : super('v4/room', null, getParameters: params.toJson());
|
||||
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ import 'getRoomResponse.dart';
|
||||
|
||||
class GetRoomCache extends RequestCache<GetRoomResponse> {
|
||||
GetRoomCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
|
||||
start("MarianumMobile", "nc-rooms");
|
||||
start('MarianumMobile', 'nc-rooms');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -19,10 +19,10 @@ class GetRoomResponse extends ApiResponse {
|
||||
final buffer = StringBuffer();
|
||||
|
||||
if(favoritesToTop) {
|
||||
buffer.write(chat.isFavorite ? "b" : "a");
|
||||
buffer.write(chat.isFavorite ? 'b' : 'a');
|
||||
}
|
||||
if(unreadToTop) {
|
||||
buffer.write(chat.unreadMessages > 0 ? "b" : "a");
|
||||
buffer.write(chat.unreadMessages > 0 ? 'b' : 'a');
|
||||
}
|
||||
|
||||
buffer.write(chat.lastActivity);
|
||||
@ -152,16 +152,16 @@ enum GetRoomResponseObjectParticipantNotificationLevel {
|
||||
// }
|
||||
|
||||
enum GetRoomResponseObjectMessageActorType {
|
||||
@JsonValue("deleted_users") deletedUsers,
|
||||
@JsonValue("users") user,
|
||||
@JsonValue("guests") guest,
|
||||
@JsonValue("bots") bot,
|
||||
@JsonValue("bridged") bridge,
|
||||
@JsonValue('deleted_users') deletedUsers,
|
||||
@JsonValue('users') user,
|
||||
@JsonValue('guests') guest,
|
||||
@JsonValue('bots') bot,
|
||||
@JsonValue('bridged') bridge,
|
||||
}
|
||||
|
||||
enum GetRoomResponseObjectMessageType {
|
||||
@JsonValue("comment") comment,
|
||||
@JsonValue("comment_deleted") deletedComment,
|
||||
@JsonValue("system") system,
|
||||
@JsonValue("command") command,
|
||||
@JsonValue('comment') comment,
|
||||
@JsonValue('comment_deleted') deletedComment,
|
||||
@JsonValue('system') system,
|
||||
@JsonValue('command') command,
|
||||
}
|
@ -7,7 +7,7 @@ import 'sendMessageParams.dart';
|
||||
|
||||
class SendMessage extends TalkApi {
|
||||
String chatToken;
|
||||
SendMessage(this.chatToken, SendMessageParams params) : super("v1/chat/$chatToken", params);
|
||||
SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ class SetFavorite extends TalkApi {
|
||||
String chatToken;
|
||||
bool favoriteState;
|
||||
|
||||
SetFavorite(this.chatToken, this.favoriteState) : super("v4/room/$chatToken/favorite", null);
|
||||
SetFavorite(this.chatToken, this.favoriteState) : super('v4/room/$chatToken/favorite', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -10,7 +10,7 @@ class SetReadMarker extends TalkApi {
|
||||
bool readState;
|
||||
SetReadMarkerParams? setReadMarkerParams;
|
||||
|
||||
SetReadMarker(this.chatToken, this.readState, {this.setReadMarkerParams}) : super("v1/chat/$chatToken/read", null, getParameters: setReadMarkerParams?.toJson()) {
|
||||
SetReadMarker(this.chatToken, this.readState, {this.setReadMarkerParams}) : super('v1/chat/$chatToken/read', null, getParameters: setReadMarkerParams?.toJson()) {
|
||||
if(readState) assert(setReadMarkerParams?.lastReadMessage != null);
|
||||
}
|
||||
|
||||
|
@ -34,21 +34,21 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
getParameters?.update(key, (value) => value.toString());
|
||||
});
|
||||
|
||||
Uri endpoint = Uri.https("${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}", "${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path", getParameters);
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
|
||||
|
||||
headers ??= {};
|
||||
headers?.putIfAbsent("Accept", () => "application/json");
|
||||
headers?.putIfAbsent("OCS-APIRequest", () => "true");
|
||||
headers?.putIfAbsent('Accept', () => 'application/json');
|
||||
headers?.putIfAbsent('OCS-APIRequest', () => 'true');
|
||||
|
||||
http.Response? data;
|
||||
|
||||
try {
|
||||
data = await request(endpoint, body, headers);
|
||||
if(data == null) throw Exception("No response Data");
|
||||
if(data == null) throw Exception('No response Data');
|
||||
if(data.statusCode >= 400 || data.statusCode < 200) throw Exception("Response status code '${data.statusCode}' might indicate an error");
|
||||
} catch(e) {
|
||||
log(e.toString());
|
||||
throw ApiError("Request $endpoint could not be dispatched: ${e.toString()}");
|
||||
throw ApiError('Request $endpoint could not be dispatched: ${e.toString()}');
|
||||
}
|
||||
//dynamic jsonData = jsonDecode(data.body);
|
||||
|
||||
@ -59,10 +59,10 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
return assembled;
|
||||
} catch (e) {
|
||||
// TODO report error
|
||||
log("Error assembling Talk API ${T.toString()} message: ${e.toString()} response on ${endpoint.path} with request body: $body and request headers: ${headers.toString()}");
|
||||
log('Error assembling Talk API ${T.toString()} message: ${e.toString()} response on ${endpoint.path} with request body: $body and request headers: ${headers.toString()}');
|
||||
}
|
||||
|
||||
throw Exception("Error assembling Talk API response");
|
||||
throw Exception('Error assembling Talk API response');
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,6 @@ class TalkError {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Talk - $status - ($code): $message";
|
||||
return 'Talk - $status - ($code): $message';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user