Skip to content

Commit

Permalink
Remove Rendering Report (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppupha authored Nov 2, 2023
1 parent 8aee924 commit 9236d8b
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 202 deletions.
4 changes: 0 additions & 4 deletions lib/common/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -262,9 +261,6 @@ Future<void> setup() async {
mainnetDB.draftCustomerSupportDao,
CustomerSupportApi(authenticatedDio,
baseUrl: Environment.customerSupportURL),
RenderingReportApi(authenticatedDio,
baseUrl: Environment.renderingReportURL),
injector(),
injector(),
mainnetDB.announcementDao,
AnnouncementApi(authenticatedDio,
Expand Down
21 changes: 0 additions & 21 deletions lib/gateway/rendering_report_api.dart

This file was deleted.

78 changes: 0 additions & 78 deletions lib/gateway/rendering_report_api.g.dart

This file was deleted.

93 changes: 1 addition & 92 deletions lib/service/customer_support_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -82,13 +76,6 @@ abstract class CustomerSupportService {

Future rateIssue(String issueID, int rating);

Future<String> createRenderingIssueReport(
AssetToken token,
List<String> topics,
);

Future reportIPFSLoadingError(AssetToken token);

Future<void> removeErrorMessage(String uuid, {bool isDelete = false});

void sendMessageFail(String uuid);
Expand All @@ -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;
Expand All @@ -132,8 +117,6 @@ class CustomerSupportServiceImpl extends CustomerSupportService {
CustomerSupportServiceImpl(
this._draftCustomerSupportDao,
this._customerSupportApi,
this._renderingReportApi,
this._accountService,
this._configurationService,
this._announcementDao,
this._announcementApi);
Expand Down Expand Up @@ -412,69 +395,6 @@ class CustomerSupportServiceImpl extends CustomerSupportService {
return await _customerSupportApi.createIssue(payload);
}

@override
Future<String> createRenderingIssueReport(
AssetToken token,
List<String> 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<PostedMessageResponse> commentIssue(String issueID, String? message,
List<SendAttachment>? attachments) async {
final payload = {
Expand Down Expand Up @@ -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<List<ChatThread>> getIssuesAndAnnouncement() async {
List<ChatThread> result = [];
Expand Down
7 changes: 0 additions & 7 deletions lib/view/artwork_common_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -533,12 +532,6 @@ class _BrokenTokenWidgetState extends State<BrokenTokenWidget>
with AfterLayoutMixin<BrokenTokenWidget> {
final metricClient = injector.get<MetricClientService>();

@override
void initState() {
injector<CustomerSupportService>().reportIPFSLoadingError(widget.token);
super.initState();
}

@override
void afterFirstLayout(BuildContext context) {
metricClient.addEvent(
Expand Down

0 comments on commit 9236d8b

Please sign in to comment.