mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
Add mappings for some file types to Viewtype / MIME type
Namely: ppt, pptx, xls, heif, heic, avif, txt. But use Viewtype::File for medias without uniform support on all platforms.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
- Move format=flowed support to a separate crate #3869
|
||||
- cargo: bump quick-xml from 0.23.0 to 0.26.0 #3722
|
||||
- Add fuzzing tests #3853
|
||||
- Add mappings for some file types to Viewtype / MIME type #3881
|
||||
|
||||
### API-Changes
|
||||
- jsonrpc: add python API for webxdc updates #3872
|
||||
|
||||
2
python/tests/data/r
Normal file
2
python/tests/data/r
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
hello
|
||||
@@ -450,24 +450,25 @@ class TestOfflineChat:
|
||||
assert msg.filemime == "image/png"
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"typein,typeout",
|
||||
"fn,typein,typeout",
|
||||
[
|
||||
(None, "application/octet-stream"),
|
||||
("text/plain", "text/plain"),
|
||||
("image/png", "image/png"),
|
||||
("r", None, "application/octet-stream"),
|
||||
("r.txt", None, "text/plain"),
|
||||
("r.txt", "text/plain", "text/plain"),
|
||||
("r.txt", "image/png", "image/png"),
|
||||
],
|
||||
)
|
||||
def test_message_file(self, ac1, chat1, data, lp, typein, typeout):
|
||||
def test_message_file(self, ac1, chat1, data, lp, fn, typein, typeout):
|
||||
lp.sec("sending file")
|
||||
fn = data.get_path("r.txt")
|
||||
msg = chat1.send_file(fn, typein)
|
||||
fp = data.get_path(fn)
|
||||
msg = chat1.send_file(fp, typein)
|
||||
assert msg
|
||||
assert msg.id > 0
|
||||
assert msg.is_file()
|
||||
assert os.path.exists(msg.filename)
|
||||
assert msg.filename.endswith(msg.basename)
|
||||
assert msg.filemime == typeout
|
||||
msg2 = chat1.send_file(fn, typein)
|
||||
msg2 = chat1.send_file(fp, typein)
|
||||
assert msg2 != msg
|
||||
assert msg2.filename != msg.filename
|
||||
|
||||
|
||||
@@ -1168,6 +1168,7 @@ pub fn guess_msgtype_from_suffix(path: &Path) -> Option<(Viewtype, &str)> {
|
||||
"3gp" => (Viewtype::Video, "video/3gpp"),
|
||||
"aac" => (Viewtype::Audio, "audio/aac"),
|
||||
"avi" => (Viewtype::Video, "video/x-msvideo"),
|
||||
"avif" => (Viewtype::File, "image/avif"), // supported since Android 12 / iOS 16
|
||||
"doc" => (Viewtype::File, "application/msword"),
|
||||
"docx" => (
|
||||
Viewtype::File,
|
||||
@@ -1176,6 +1177,8 @@ pub fn guess_msgtype_from_suffix(path: &Path) -> Option<(Viewtype, &str)> {
|
||||
"epub" => (Viewtype::File, "application/epub+zip"),
|
||||
"flac" => (Viewtype::Audio, "audio/flac"),
|
||||
"gif" => (Viewtype::Gif, "image/gif"),
|
||||
"heic" => (Viewtype::File, "image/heic"), // supported since Android 10 / iOS 11
|
||||
"heif" => (Viewtype::File, "image/heif"), // supported since Android 10 / iOS 11
|
||||
"html" => (Viewtype::File, "text/html"),
|
||||
"htm" => (Viewtype::File, "text/html"),
|
||||
"ico" => (Viewtype::File, "image/vnd.microsoft.icon"),
|
||||
@@ -1200,10 +1203,15 @@ pub fn guess_msgtype_from_suffix(path: &Path) -> Option<(Viewtype, &str)> {
|
||||
"oga" => (Viewtype::Audio, "audio/ogg"),
|
||||
"ogg" => (Viewtype::Audio, "audio/ogg"),
|
||||
"ogv" => (Viewtype::File, "video/ogg"),
|
||||
"opus" => (Viewtype::File, "audio/ogg"), // not supported eg. on Android 4
|
||||
"opus" => (Viewtype::File, "audio/ogg"), // supported since Android 10
|
||||
"otf" => (Viewtype::File, "font/otf"),
|
||||
"pdf" => (Viewtype::File, "application/pdf"),
|
||||
"png" => (Viewtype::Image, "image/png"),
|
||||
"ppt" => (Viewtype::File, "application/vnd.ms-powerpoint"),
|
||||
"pptx" => (
|
||||
Viewtype::File,
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
),
|
||||
"rar" => (Viewtype::File, "application/vnd.rar"),
|
||||
"rtf" => (Viewtype::File, "application/rtf"),
|
||||
"spx" => (Viewtype::File, "audio/ogg"), // Ogg Speex Profile
|
||||
@@ -1212,6 +1220,7 @@ pub fn guess_msgtype_from_suffix(path: &Path) -> Option<(Viewtype, &str)> {
|
||||
"tiff" => (Viewtype::File, "image/tiff"),
|
||||
"tif" => (Viewtype::File, "image/tiff"),
|
||||
"ttf" => (Viewtype::File, "font/ttf"),
|
||||
"txt" => (Viewtype::File, "text/plain"),
|
||||
"vcard" => (Viewtype::File, "text/vcard"),
|
||||
"vcf" => (Viewtype::File, "text/vcard"),
|
||||
"wav" => (Viewtype::File, "audio/wav"),
|
||||
@@ -1221,11 +1230,12 @@ pub fn guess_msgtype_from_suffix(path: &Path) -> Option<(Viewtype, &str)> {
|
||||
"wmv" => (Viewtype::Video, "video/x-ms-wmv"),
|
||||
"xdc" => (Viewtype::Webxdc, "application/webxdc+zip"),
|
||||
"xhtml" => (Viewtype::File, "application/xhtml+xml"),
|
||||
"xls" => (Viewtype::File, "application/vnd.ms-excel"),
|
||||
"xlsx" => (
|
||||
Viewtype::File,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
),
|
||||
"xml" => (Viewtype::File, "application/vnd.ms-excel"),
|
||||
"xml" => (Viewtype::File, "application/xml"),
|
||||
"zip" => (Viewtype::File, "application/zip"),
|
||||
_ => {
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user