Never silently truncate the draft when attaching an IPFS link

Check before uploading that the link (from the gateway and a CIDv1-sized
placeholder) fits with the draft and the reply prefix, and tell the user
when it doesn't instead of cutting their text. The channel limit now
counts the @[name] reply prefix like the send path.
This commit is contained in:
zjs81 committed 2026-10-24 21:57:55 -07:00
1 parent 084a8fb98b
commit 34db64d7af
25 files changed
+315 -103

No files matched your search

+14 -2
View File
@@ -22,6 +22,19 @@ class IpfsUploadHelper {
static final _kuboAddPath = RegExp(r'/api/v0/add/?$');
/// A CIDv1 (base32, sha2-256) as long as the CID of every upload, used to
/// size the link before uploading.
static const sampleCid =
'bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku';
static String linkForCid({
required String uploadGateway,
required String cid,
}) {
final gateway = normalizeIpfsGateway(uploadGateway);
return gateway.isEmpty ? 'ipfs://$cid' : '$gateway$cid';
}
static String mimeTypeForFileName(String fileName) {
switch (fileName.toLowerCase().split('.').last) {
case 'jpg':
@@ -149,8 +162,7 @@ class IpfsUploadHelper {
);
}
final gateway = normalizeIpfsGateway(uploadGateway);
return gateway.isEmpty ? 'ipfs://$cid' : '$gateway$cid';
return linkForCid(uploadGateway: uploadGateway, cid: cid);
}
static Future<void> _copyKuboFileToMfs({