diff --git a/lib/common/injector.dart b/lib/common/injector.dart index 8995f2ac7..3dbf9f66e 100644 --- a/lib/common/injector.dart +++ b/lib/common/injector.dart @@ -24,7 +24,6 @@ import 'package:autonomy_flutter/gateway/feralfile_api.dart'; import 'package:autonomy_flutter/gateway/iap_api.dart'; import 'package:autonomy_flutter/gateway/postcard_api.dart'; import 'package:autonomy_flutter/gateway/pubdoc_api.dart'; -import 'package:autonomy_flutter/gateway/rendering_report_api.dart'; import 'package:autonomy_flutter/gateway/tzkt_api.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart'; import 'package:autonomy_flutter/screen/playlists/add_new_playlist/add_new_playlist_bloc.dart'; @@ -262,9 +261,6 @@ Future setup() async { mainnetDB.draftCustomerSupportDao, CustomerSupportApi(authenticatedDio, baseUrl: Environment.customerSupportURL), - RenderingReportApi(authenticatedDio, - baseUrl: Environment.renderingReportURL), - injector(), injector(), mainnetDB.announcementDao, AnnouncementApi(authenticatedDio, diff --git a/lib/gateway/rendering_report_api.dart b/lib/gateway/rendering_report_api.dart deleted file mode 100644 index 838a4137a..000000000 --- a/lib/gateway/rendering_report_api.dart +++ /dev/null @@ -1,21 +0,0 @@ -// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// Copyright © 2022 Bitmark. All rights reserved. -// Use of this source code is governed by the BSD-2-Clause Plus Patent License -// that can be found in the LICENSE file. -// - -import 'package:dio/dio.dart'; -import 'package:retrofit/retrofit.dart'; - -part 'rendering_report_api.g.dart'; - -@RestApi(baseUrl: "") -abstract class RenderingReportApi { - factory RenderingReportApi(Dio dio, {String baseUrl}) = _RenderingReportApi; - - @POST("/v1/reports/") - Future> report( - @Body() Map body, - ); -} diff --git a/lib/gateway/rendering_report_api.g.dart b/lib/gateway/rendering_report_api.g.dart deleted file mode 100644 index 7a55293af..000000000 --- a/lib/gateway/rendering_report_api.g.dart +++ /dev/null @@ -1,78 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'rendering_report_api.dart'; - -// ************************************************************************** -// RetrofitGenerator -// ************************************************************************** - -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers - -class _RenderingReportApi implements RenderingReportApi { - _RenderingReportApi( - this._dio, { - this.baseUrl, - }); - - final Dio _dio; - - String? baseUrl; - - @override - Future> report(Map body) async { - const _extra = {}; - final queryParameters = {}; - final _headers = {}; - final _data = {}; - _data.addAll(body); - final _result = await _dio.fetch>( - _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/v1/reports/', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final value = _result.data!.cast(); - return value; - } - - RequestOptions _setStreamType(RequestOptions requestOptions) { - if (T != dynamic && - !(requestOptions.responseType == ResponseType.bytes || - requestOptions.responseType == ResponseType.stream)) { - if (T == String) { - requestOptions.responseType = ResponseType.plain; - } else { - requestOptions.responseType = ResponseType.json; - } - } - return requestOptions; - } - - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { - if (baseUrl == null || baseUrl.trim().isEmpty) { - return dioBaseUrl; - } - - final url = Uri.parse(baseUrl); - - if (url.isAbsolute) { - return url.toString(); - } - - return Uri.parse(dioBaseUrl).resolveUri(url).toString(); - } -} diff --git a/lib/service/customer_support_service.dart b/lib/service/customer_support_service.dart index 4ee140bba..8c42f42af 100644 --- a/lib/service/customer_support_service.dart +++ b/lib/service/customer_support_service.dart @@ -15,26 +15,20 @@ import 'package:autonomy_flutter/database/entity/announcement_local.dart'; import 'package:autonomy_flutter/database/entity/draft_customer_support.dart'; import 'package:autonomy_flutter/gateway/announcement_api.dart'; import 'package:autonomy_flutter/gateway/customer_support_api.dart'; -import 'package:autonomy_flutter/gateway/rendering_report_api.dart'; import 'package:autonomy_flutter/model/customer_support.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/screen/customer_support/support_thread_page.dart'; -import 'package:autonomy_flutter/service/account_service.dart'; import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/service/navigation_service.dart'; import 'package:autonomy_flutter/util/constants.dart'; -import 'package:autonomy_flutter/util/custom_exception.dart'; import 'package:autonomy_flutter/util/device.dart'; import 'package:autonomy_flutter/util/inapp_notifications.dart'; import 'package:autonomy_flutter/util/log.dart'; import 'package:autonomy_flutter/view/user_agent_utils.dart'; import 'package:autonomy_theme/autonomy_theme.dart'; import 'package:collection/collection.dart'; -import 'package:crypto/crypto.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:hive/hive.dart'; -import 'package:nft_collection/models/asset_token.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:path_provider/path_provider.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; @@ -82,13 +76,6 @@ abstract class CustomerSupportService { Future rateIssue(String issueID, int rating); - Future createRenderingIssueReport( - AssetToken token, - List topics, - ); - - Future reportIPFSLoadingError(AssetToken token); - Future removeErrorMessage(String uuid, {bool isDelete = false}); void sendMessageFail(String uuid); @@ -105,12 +92,10 @@ abstract class CustomerSupportService { } class CustomerSupportServiceImpl extends CustomerSupportService { - static const int _ipfsReportThreshold = 24 * 60 * 60 * 1000; // 1 day. +// 1 day. final DraftCustomerSupportDao _draftCustomerSupportDao; final CustomerSupportApi _customerSupportApi; - final RenderingReportApi _renderingReportApi; - final AccountService _accountService; final ConfigurationService _configurationService; final AnnouncementLocalDao _announcementDao; final AnnouncementApi _announcementApi; @@ -132,8 +117,6 @@ class CustomerSupportServiceImpl extends CustomerSupportService { CustomerSupportServiceImpl( this._draftCustomerSupportDao, this._customerSupportApi, - this._renderingReportApi, - this._accountService, this._configurationService, this._announcementDao, this._announcementApi); @@ -412,69 +395,6 @@ class CustomerSupportServiceImpl extends CustomerSupportService { return await _customerSupportApi.createIssue(payload); } - @override - Future createRenderingIssueReport( - AssetToken token, - List topics, - ) async { - /** Generate metadata - * Format: - * [Platform - Version - HashedAccountDID] - * [TokenIndexerID - Topices] - */ - var metadata = ""; - - final defaultAccount = await _accountService.getDefaultAccount(); - final accountDID = await defaultAccount.getAccountDID(); - final accountHMACSecret = - await _configurationService.getAccountHMACSecret(); - - final hashedAccountID = Hmac(sha256, utf8.encode(accountHMACSecret)) - .convert(utf8.encode(accountDID)); - - String platform = ""; - if (Platform.isIOS) { - platform = "iOS"; - } else if (Platform.isAndroid) { - platform = "android"; - } - - final version = (await PackageInfo.fromPlatform()).version; - - metadata = - "\n[$platform - $version - $hashedAccountID]\n[${token.id} - ${topics.join(", ")}]"; - - // Extract Collection Value - // Etherem blockchain: => pass contract as value: k_$contractAddress - // Tezos / FeralFile blockchain => pass arworkID as value: a_$artworkID - var collection = token.contractAddress; - if (collection != null && collection.isNotEmpty) { - collection = "k_$collection"; - } - - if (collection == null || - collection.isEmpty || - ['tezos', 'bitmark'].contains(token.blockchain)) { - collection = "a_${token.assetID}"; - } - - // Request API - final payload = { - "artwork": token.assetID, - "creator": token.artistName ?? 'unknown', - "collection": collection, - "token_url": token.assetURL, - "metadata": metadata, - }; - - final result = await _renderingReportApi.report(payload); - final githubURL = result["url"]; - if (githubURL == null) { - throw SystemException("_renderingReportApi missing url $result"); - } - return githubURL; - } - Future commentIssue(String issueID, String? message, List? attachments) async { final payload = { @@ -515,17 +435,6 @@ class CustomerSupportServiceImpl extends CustomerSupportService { return _customerSupportApi.rateIssue(issueID, rating); } - @override - Future reportIPFSLoadingError(AssetToken token) async { - final reportBox = await Hive.openBox("au_ipfs_reports"); - final int lastReportTime = reportBox.get(token.id) ?? 0; - final now = DateTime.now().millisecondsSinceEpoch; - if (now > lastReportTime + _ipfsReportThreshold) { - reportBox.put(token.id, now); - await createRenderingIssueReport(token, ["IPFS Loading"]); - } - } - @override Future> getIssuesAndAnnouncement() async { List result = []; diff --git a/lib/view/artwork_common_widget.dart b/lib/view/artwork_common_widget.dart index 638a238b7..b69c03223 100644 --- a/lib/view/artwork_common_widget.dart +++ b/lib/view/artwork_common_widget.dart @@ -6,7 +6,6 @@ import 'package:after_layout/after_layout.dart'; import 'package:autonomy_flutter/common/environment.dart'; import 'package:autonomy_flutter/model/ff_account.dart'; import 'package:autonomy_flutter/service/configuration_service.dart'; -import 'package:autonomy_flutter/service/customer_support_service.dart'; import 'package:autonomy_flutter/service/feralfile_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; import 'package:autonomy_flutter/service/navigation_service.dart'; @@ -533,12 +532,6 @@ class _BrokenTokenWidgetState extends State with AfterLayoutMixin { final metricClient = injector.get(); - @override - void initState() { - injector().reportIPFSLoadingError(widget.token); - super.initState(); - } - @override void afterFirstLayout(BuildContext context) { metricClient.addEvent(