mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-05 17:47:46 +08:00
feat: edit dyn
feat: set pub setting feat: set reply interaction Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -986,4 +986,14 @@ abstract final class Api {
|
||||
'${HttpString.liveBaseUrl}/av/v1/SuperChat/report';
|
||||
|
||||
static const String imMsgReport = '${HttpString.tUrl}/x/bplus/im/report/add';
|
||||
|
||||
static const String dynPrivatePubSetting =
|
||||
'/x/dynamic/feed/dyn/private_pub_setting';
|
||||
|
||||
static const String editDyn = '/x/dynamic/feed/edit/dyn';
|
||||
|
||||
static const String replyInteraction =
|
||||
'/x/v2/reply/subject/interaction-status';
|
||||
|
||||
static const String replySubjectModify = '/x/v2/reply/subject/modify';
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/pair.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
@@ -151,7 +153,7 @@ abstract final class DynamicsHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future createDynamic({
|
||||
static Future<LoadingState<Map?>> createDynamic({
|
||||
dynamic mid,
|
||||
dynamic dynIdStr, // repost dyn
|
||||
dynamic rid, // repost video
|
||||
@@ -231,15 +233,9 @@ abstract final class DynamicsHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': res.data['data'],
|
||||
};
|
||||
return Success(res.data['data']);
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,4 +671,110 @@ abstract final class DynamicsHttp {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<Null>> dynPrivatePubSetting({
|
||||
required Object dynId,
|
||||
int? dynType,
|
||||
required String action,
|
||||
}) async {
|
||||
final res = await Request().post(
|
||||
Api.dynPrivatePubSetting,
|
||||
queryParameters: {
|
||||
'platform': 'web',
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
data: {
|
||||
"object_id": jsonEncode({
|
||||
"dyn_id": dynId.toString(),
|
||||
"dyn_type": ?dynType,
|
||||
}),
|
||||
"action": action,
|
||||
},
|
||||
options: Options(contentType: Headers.jsonContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return const Success(null);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<Null>> editDyn({
|
||||
required Object dynId,
|
||||
Object? repostDynId,
|
||||
dynamic rawText,
|
||||
List? pics,
|
||||
ReplyOptionType? replyOption,
|
||||
int? privatePub,
|
||||
List<Map<String, dynamic>>? extraContent,
|
||||
Pair<int, String>? topic,
|
||||
String? title,
|
||||
Map? attachCard,
|
||||
}) async {
|
||||
final uploadId =
|
||||
"${Accounts.main.mid}_${DateTime.now().millisecondsSinceEpoch ~/ 1000}_${Utils.random.nextInt(9000) + 1000}";
|
||||
final res = await Request().post(
|
||||
Api.editDyn,
|
||||
queryParameters: await WbiSign.makSign({
|
||||
'platform': 'web',
|
||||
'csrf': Accounts.main.csrf,
|
||||
'x-bili-device-req-json':
|
||||
'{"platform":"web","device":"pc","spmid":"333.1368"}',
|
||||
'w_dyn_req.upload_id': uploadId,
|
||||
'w_dyn_req.meta':
|
||||
'{"app_meta":{"from":"create.dynamic.web","mobi_app":"web"}}',
|
||||
}),
|
||||
data: {
|
||||
"dyn_req": {
|
||||
"content": {
|
||||
"contents": [
|
||||
if (rawText != null)
|
||||
{
|
||||
"raw_text": rawText,
|
||||
"type": 1,
|
||||
"biz_id": "",
|
||||
},
|
||||
...?extraContent,
|
||||
],
|
||||
if (title != null && title.isNotEmpty) 'title': title,
|
||||
},
|
||||
if (privatePub != null || replyOption != null)
|
||||
"option": {
|
||||
'private_pub': ?privatePub,
|
||||
if (replyOption == ReplyOptionType.close)
|
||||
"close_comment": 1
|
||||
else if (replyOption == ReplyOptionType.choose)
|
||||
"up_choose_comment": 1,
|
||||
},
|
||||
"scene": repostDynId != null
|
||||
? 4
|
||||
: pics != null
|
||||
? 2
|
||||
: 1,
|
||||
'pics': ?pics,
|
||||
"attach_card": attachCard,
|
||||
"upload_id": uploadId,
|
||||
"meta": {
|
||||
"app_meta": {"from": "create.dynamic.web", "mobi_app": "web"},
|
||||
},
|
||||
if (topic != null)
|
||||
"topic": {
|
||||
"id": topic.first,
|
||||
"name": topic.second,
|
||||
"from_source": "dyn.web.list",
|
||||
"from_topic_id": 0,
|
||||
},
|
||||
},
|
||||
"dyn_id_str": dynId.toString(),
|
||||
if (repostDynId != null)
|
||||
"web_repost_src": {"dyn_id_str": repostDynId.toString()},
|
||||
},
|
||||
options: Options(contentType: Headers.jsonContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return const Success(null);
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import 'package:PiliPlus/models_new/emote/data.dart';
|
||||
import 'package:PiliPlus/models_new/emote/package.dart';
|
||||
import 'package:PiliPlus/models_new/reply/data.dart';
|
||||
import 'package:PiliPlus/models_new/reply2reply/data.dart';
|
||||
import 'package:PiliPlus/models_new/reply_interaction/data.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
abstract final class ReplyHttp {
|
||||
static final Options options = Options(
|
||||
@@ -206,4 +208,53 @@ abstract final class ReplyHttp {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<ReplyInteractData>> replyInteraction({
|
||||
required Object oid,
|
||||
required Object type,
|
||||
}) async {
|
||||
final res = await Request().get(
|
||||
Api.replyInteraction,
|
||||
queryParameters: {
|
||||
'oid': oid,
|
||||
'type': type,
|
||||
'web_location': 333.1369,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
try {
|
||||
return Success(ReplyInteractData.fromJson(res.data['data']));
|
||||
} catch (e) {
|
||||
return Error(e.toString());
|
||||
}
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<Null>> replySubjectModify({
|
||||
required int oid,
|
||||
required int type,
|
||||
required int action,
|
||||
}) async {
|
||||
final res = await Request().post(
|
||||
Api.replySubjectModify,
|
||||
data: {
|
||||
'oid': oid,
|
||||
'type': type,
|
||||
'action': action,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
if (res.data['data']?['action_toast'] case final String toast) {
|
||||
SmartDialog.showToast(toast);
|
||||
}
|
||||
return const Success(null);
|
||||
} else {
|
||||
SmartDialog.showToast(res.data['message'].toString());
|
||||
return const Error(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user