Don't automatically convert OpenStreetMap URLs into geo:
URIs in sent messages
Updates #1850 and #2914
This commit is contained in:
parent
a57853156e
commit
ab7e879261
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 10.0.0 (Unreleased)
|
||||||
|
|
||||||
|
- Don't automatically convert OpenStreetMap URLs into `geo:` URIs in sent messages
|
||||||
|
|
||||||
## 9.1.1 (2022-05-05)
|
## 9.1.1 (2022-05-05)
|
||||||
|
|
||||||
- GIFs don't render inside unfurls and cause a TypeError
|
- GIFs don't render inside unfurls and cause a TypeError
|
||||||
|
@ -889,7 +889,7 @@ const ChatBox = ModelWithContact.extend({
|
|||||||
const is_spoiler = !!this.get('composing_spoiler');
|
const is_spoiler = !!this.get('composing_spoiler');
|
||||||
const origin_id = u.getUniqueId();
|
const origin_id = u.getUniqueId();
|
||||||
const text = attrs?.body;
|
const text = attrs?.body;
|
||||||
const body = text ? u.httpToGeoUri(u.shortnamesToUnicode(text), _converse) : undefined;
|
const body = text ? u.shortnamesToUnicode(text) : undefined;
|
||||||
attrs = Object.assign({}, attrs, {
|
attrs = Object.assign({}, attrs, {
|
||||||
'from': _converse.bare_jid,
|
'from': _converse.bare_jid,
|
||||||
'fullname': _converse.xmppstatus.get('fullname'),
|
'fullname': _converse.xmppstatus.get('fullname'),
|
||||||
|
@ -987,7 +987,7 @@ const ChatRoomMixin = {
|
|||||||
[text, references] = this.parseTextForReferences(attrs.body);
|
[text, references] = this.parseTextForReferences(attrs.body);
|
||||||
}
|
}
|
||||||
const origin_id = getUniqueId();
|
const origin_id = getUniqueId();
|
||||||
const body = text ? u.httpToGeoUri(u.shortnamesToUnicode(text), _converse) : undefined;
|
const body = text ? u.shortnamesToUnicode(text) : undefined;
|
||||||
attrs = Object.assign({}, attrs, {
|
attrs = Object.assign({}, attrs, {
|
||||||
body,
|
body,
|
||||||
is_spoiler,
|
is_spoiler,
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @property { String } [credentials_url] - URL from where login credentials can be fetched
|
* @property { String } [credentials_url] - URL from where login credentials can be fetched
|
||||||
* @property { Boolean } [discover_connection_methods=true]
|
* @property { Boolean } [discover_connection_methods=true]
|
||||||
* @property { RegExp } [geouri_regex]
|
* @property { RegExp } [geouri_regex]
|
||||||
* @property { RegExp } [geouri_replacement='https - //www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2']
|
* @property { RegExp } [geouri_replacement='https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2']
|
||||||
* @property { String } [i18n]
|
* @property { String } [i18n]
|
||||||
* @property { String } [jid]
|
* @property { String } [jid]
|
||||||
* @property { Boolean } [keepalive=true]
|
* @property { Boolean } [keepalive=true]
|
||||||
|
@ -459,11 +459,6 @@ export function getUniqueId (suffix) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u.httpToGeoUri = function(text) {
|
|
||||||
const replacement = 'geo:$1,$2';
|
|
||||||
return text.replace(settings_api.get("geouri_regex"), replacement);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the specified timeout and interval.
|
* Clears the specified timeout and interval.
|
||||||
|
@ -262,6 +262,23 @@ describe("A Chat Message", function () {
|
|||||||
expect(_converse.api.chatboxes.get).not.toHaveBeenCalled();
|
expect(_converse.api.chatboxes.get).not.toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it("will render Openstreetmap-URL from geo-URI",
|
||||||
|
mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) {
|
||||||
|
|
||||||
|
await mock.waitForRoster(_converse, 'current', 1);
|
||||||
|
const message = "geo:37.786971,-122.399677";
|
||||||
|
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
|
||||||
|
await mock.openChatBoxFor(_converse, contact_jid);
|
||||||
|
const view = _converse.chatboxviews.get(contact_jid);
|
||||||
|
spyOn(view.model, 'sendMessage').and.callThrough();
|
||||||
|
await mock.sendMessage(view, message);
|
||||||
|
await u.waitUntil(() => view.querySelectorAll('.chat-content .chat-msg').length, 1000);
|
||||||
|
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||||
|
const msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop();
|
||||||
|
await u.waitUntil(() => msg.innerHTML.replace(/\<!-.*?-\>/g, '') ===
|
||||||
|
'<a target="_blank" rel="noopener" href="https://www.openstreetmap.org/?mlat=37.786971&'+
|
||||||
|
'mlon=-122.399677#map=18/37.786971/-122.399677">https://www.openstreetmap.org/?mlat=37.786971&mlon=-122.399677#map=18/37.786971/-122.399677</a>');
|
||||||
|
}));
|
||||||
|
|
||||||
it("can be a carbon message, as defined in XEP-0280",
|
it("can be a carbon message, as defined in XEP-0280",
|
||||||
mock.initConverse([], {}, async function (_converse) {
|
mock.initConverse([], {}, async function (_converse) {
|
||||||
@ -799,6 +816,7 @@ describe("A Chat Message", function () {
|
|||||||
"Another message within 10 minutes, but from a different person");
|
"Another message within 10 minutes, but from a different person");
|
||||||
|
|
||||||
jasmine.clock().uninstall();
|
jasmine.clock().uninstall();
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*global mock, converse */
|
/*global mock, converse */
|
||||||
|
|
||||||
const $msg = converse.env.$msg;
|
const { $msg, u } = converse.env;
|
||||||
const u = converse.env.utils;
|
|
||||||
const sizzle = converse.env.sizzle;
|
|
||||||
|
|
||||||
|
|
||||||
describe("A chat message", function () {
|
describe("A chat message", function () {
|
||||||
@ -206,24 +204,6 @@ describe("A Minimized ChatBoxView's Unread Message Count", function () {
|
|||||||
expect(u.isVisible(unread_count)).toBeTruthy();
|
expect(u.isVisible(unread_count)).toBeTruthy();
|
||||||
expect(unread_count.innerHTML.replace(/<!-.*?->/g, '')).toBe('1');
|
expect(unread_count.innerHTML.replace(/<!-.*?->/g, '')).toBe('1');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("will render Openstreetmap-URL from geo-URI",
|
|
||||||
mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) {
|
|
||||||
|
|
||||||
await mock.waitForRoster(_converse, 'current', 1);
|
|
||||||
const message = "geo:37.786971,-122.399677";
|
|
||||||
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
|
|
||||||
await mock.openChatBoxFor(_converse, contact_jid);
|
|
||||||
const view = _converse.chatboxviews.get(contact_jid);
|
|
||||||
spyOn(view.model, 'sendMessage').and.callThrough();
|
|
||||||
await mock.sendMessage(view, message);
|
|
||||||
await u.waitUntil(() => view.querySelectorAll('.chat-content .chat-msg').length, 1000);
|
|
||||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
|
||||||
const msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop();
|
|
||||||
await u.waitUntil(() => msg.innerHTML.replace(/\<!-.*?-\>/g, '') ===
|
|
||||||
'<a target="_blank" rel="noopener" href="https://www.openstreetmap.org/?mlat=37.786971&'+
|
|
||||||
'mlon=-122.399677#map=18/37.786971/-122.399677">https://www.openstreetmap.org/?mlat=37.786971&mlon=-122.399677#map=18/37.786971/-122.399677</a>');
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user