Replys to ActivityPub should start with @someone
This commit is contained in:
parent
4d97922933
commit
c25c600417
40
core/fse.js
40
core/fse.js
|
@ -21,6 +21,7 @@ const {
|
||||||
messageInfoFromAddressedToInfo,
|
messageInfoFromAddressedToInfo,
|
||||||
setExternalAddressedToInfo,
|
setExternalAddressedToInfo,
|
||||||
copyExternalAddressedToInfo,
|
copyExternalAddressedToInfo,
|
||||||
|
getReplyToMessagePrefix,
|
||||||
} = require('./mail_util.js');
|
} = require('./mail_util.js');
|
||||||
const Events = require('./events.js');
|
const Events = require('./events.js');
|
||||||
const UserProps = require('./user_property.js');
|
const UserProps = require('./user_property.js');
|
||||||
|
@ -28,10 +29,10 @@ const SysProps = require('./system_property.js');
|
||||||
const FileArea = require('./file_base_area.js');
|
const FileArea = require('./file_base_area.js');
|
||||||
const FileEntry = require('./file_entry.js');
|
const FileEntry = require('./file_entry.js');
|
||||||
const DownloadQueue = require('./download_queue.js');
|
const DownloadQueue = require('./download_queue.js');
|
||||||
|
const EngiAssert = require('./enigma_assert.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const assert = require('assert');
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const fse = require('fs-extra');
|
const fse = require('fs-extra');
|
||||||
|
@ -123,7 +124,7 @@ exports.FullScreenEditorModule =
|
||||||
this.editorMode = config.editorMode;
|
this.editorMode = config.editorMode;
|
||||||
|
|
||||||
if (config.messageAreaTag) {
|
if (config.messageAreaTag) {
|
||||||
// :TODO: swtich to this.config.messageAreaTag so we can follow Object.assign pattern for config/extraArgs
|
// :TODO: switch to this.config.messageAreaTag so we can follow Object.assign pattern for config/extraArgs
|
||||||
this.messageAreaTag = config.messageAreaTag;
|
this.messageAreaTag = config.messageAreaTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +252,7 @@ exports.FullScreenEditorModule =
|
||||||
if (self.newQuoteBlock) {
|
if (self.newQuoteBlock) {
|
||||||
self.newQuoteBlock = false;
|
self.newQuoteBlock = false;
|
||||||
|
|
||||||
// :TODO: If replying to ANSI, add a blank sepration line here
|
// :TODO: If replying to ANSI, add a blank separation line here
|
||||||
|
|
||||||
quoteMsgView.addText(self.getQuoteByHeader());
|
quoteMsgView.addText(self.getQuoteByHeader());
|
||||||
}
|
}
|
||||||
|
@ -480,7 +481,10 @@ exports.FullScreenEditorModule =
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
|
||||||
this.updateLastReadId(() => {
|
this.updateLastReadId(() => {
|
||||||
if (this.isReady) {
|
if (!this.isReady) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.initHeaderViewMode();
|
this.initHeaderViewMode();
|
||||||
this.initFooterViewMode();
|
this.initFooterViewMode();
|
||||||
|
|
||||||
|
@ -581,7 +585,6 @@ exports.FullScreenEditorModule =
|
||||||
bodyMessageView.setText(controlCodesToAnsi(msg));
|
bodyMessageView.setText(controlCodesToAnsi(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,7 +852,7 @@ exports.FullScreenEditorModule =
|
||||||
const self = this;
|
const self = this;
|
||||||
var art = self.menuConfig.config.art;
|
var art = self.menuConfig.config.art;
|
||||||
|
|
||||||
assert(_.isObject(art));
|
EngiAssert(_.isObject(art));
|
||||||
|
|
||||||
async.waterfall(
|
async.waterfall(
|
||||||
[
|
[
|
||||||
|
@ -1161,7 +1164,7 @@ exports.FullScreenEditorModule =
|
||||||
}
|
}
|
||||||
|
|
||||||
initHeaderReplyEditMode() {
|
initHeaderReplyEditMode() {
|
||||||
assert(_.isObject(this.replyToMessage));
|
EngiAssert(_.isObject(this.replyToMessage));
|
||||||
|
|
||||||
this.setHeaderText(MciViewIds.header.to, this.replyToMessage.fromUserName);
|
this.setHeaderText(MciViewIds.header.to, this.replyToMessage.fromUserName);
|
||||||
|
|
||||||
|
@ -1177,6 +1180,20 @@ exports.FullScreenEditorModule =
|
||||||
this.setHeaderText(MciViewIds.header.subject, newSubj);
|
this.setHeaderText(MciViewIds.header.subject, newSubj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initBodyReplyEditMode() {
|
||||||
|
EngiAssert(_.isObject(this.replyToMessage));
|
||||||
|
|
||||||
|
const bodyMessageView = this.viewControllers.body.getView(
|
||||||
|
MciViewIds.body.message
|
||||||
|
);
|
||||||
|
|
||||||
|
const messagePrefix = getReplyToMessagePrefix(
|
||||||
|
this.replyToMessage.fromUserName
|
||||||
|
);
|
||||||
|
|
||||||
|
bodyMessageView.setText(messagePrefix);
|
||||||
|
}
|
||||||
|
|
||||||
initFooterViewMode() {
|
initFooterViewMode() {
|
||||||
this.setViewText(
|
this.setViewText(
|
||||||
'footerView',
|
'footerView',
|
||||||
|
@ -1450,11 +1467,18 @@ exports.FullScreenEditorModule =
|
||||||
switchToBody() {
|
switchToBody() {
|
||||||
const to = this.getView('header', MciViewIds.header.to).getData();
|
const to = this.getView('header', MciViewIds.header.to).getData();
|
||||||
const msgInfo = messageInfoFromAddressedToInfo(getAddressedToInfo(to));
|
const msgInfo = messageInfoFromAddressedToInfo(getAddressedToInfo(to));
|
||||||
if (msgInfo.maxMessageLength > 0) {
|
|
||||||
const bodyView = this.getView('body', MciViewIds.body.message);
|
const bodyView = this.getView('body', MciViewIds.body.message);
|
||||||
|
|
||||||
|
if (msgInfo.maxMessageLength > 0) {
|
||||||
bodyView.maxLength = msgInfo.maxMessageLength;
|
bodyView.maxLength = msgInfo.maxMessageLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// first pass through, init body (we may need header values set)
|
||||||
|
const bodyText = bodyView.getData();
|
||||||
|
if (!bodyText && this.isReply()) {
|
||||||
|
this.initBodyReplyEditMode();
|
||||||
|
}
|
||||||
|
|
||||||
this.viewControllers.header.setFocus(false);
|
this.viewControllers.header.setFocus(false);
|
||||||
this.viewControllers.body.switchFocus(1);
|
this.viewControllers.body.switchFocus(1);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ exports.setExternalAddressedToInfo = setExternalAddressedToInfo;
|
||||||
exports.copyExternalAddressedToInfo = copyExternalAddressedToInfo;
|
exports.copyExternalAddressedToInfo = copyExternalAddressedToInfo;
|
||||||
exports.messageInfoFromAddressedToInfo = messageInfoFromAddressedToInfo;
|
exports.messageInfoFromAddressedToInfo = messageInfoFromAddressedToInfo;
|
||||||
exports.getQuotePrefixFromName = getQuotePrefixFromName;
|
exports.getQuotePrefixFromName = getQuotePrefixFromName;
|
||||||
|
exports.getReplyToMessagePrefix = getReplyToMessagePrefix;
|
||||||
|
|
||||||
const EMAIL_REGEX =
|
const EMAIL_REGEX =
|
||||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}]?)|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}]?)|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
|
@ -32,6 +33,11 @@ const EMAIL_REGEX =
|
||||||
foo@host.com { name : 'foo', flavor : 'email', remote : 'foo@host.com' }
|
foo@host.com { name : 'foo', flavor : 'email', remote : 'foo@host.com' }
|
||||||
Bar <baz@foobar.net> { name : 'Bar', flavor : 'email', remote : 'baz@foobar.com' }
|
Bar <baz@foobar.net> { name : 'Bar', flavor : 'email', remote : 'baz@foobar.com' }
|
||||||
@JoeUser@some.host.com { name : 'JoeUser', flavor : 'activitypub', remote 'JoeUser@some.host.com' }
|
@JoeUser@some.host.com { name : 'JoeUser', flavor : 'activitypub', remote 'JoeUser@some.host.com' }
|
||||||
|
|
||||||
|
Fields:
|
||||||
|
- name : user/display name
|
||||||
|
- flavor : remote flavor - FTN/etc.
|
||||||
|
- remote : Address in remote format, if applicable
|
||||||
*/
|
*/
|
||||||
function getAddressedToInfo(input) {
|
function getAddressedToInfo(input) {
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
|
@ -41,17 +47,26 @@ function getAddressedToInfo(input) {
|
||||||
if (firstAtPos < 0) {
|
if (firstAtPos < 0) {
|
||||||
let addr = Address.fromString(input);
|
let addr = Address.fromString(input);
|
||||||
if (Address.isValidAddress(addr)) {
|
if (Address.isValidAddress(addr)) {
|
||||||
return { flavor: MessageConst.AddressFlavor.FTN, remote: input };
|
return {
|
||||||
|
flavor: MessageConst.AddressFlavor.FTN,
|
||||||
|
remote: input,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const lessThanPos = input.indexOf('<');
|
const lessThanPos = input.indexOf('<');
|
||||||
if (lessThanPos < 0) {
|
if (lessThanPos < 0) {
|
||||||
return { name: input, flavor: MessageConst.AddressFlavor.Local };
|
return {
|
||||||
|
name: input,
|
||||||
|
flavor: MessageConst.AddressFlavor.Local,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const greaterThanPos = input.indexOf('>');
|
const greaterThanPos = input.indexOf('>');
|
||||||
if (greaterThanPos < lessThanPos) {
|
if (greaterThanPos < lessThanPos) {
|
||||||
return { name: input, flavor: MessageConst.AddressFlavor.Local };
|
return {
|
||||||
|
name: input,
|
||||||
|
flavor: MessageConst.AddressFlavor.Local,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = Address.fromString(input.slice(lessThanPos + 1, greaterThanPos));
|
addr = Address.fromString(input.slice(lessThanPos + 1, greaterThanPos));
|
||||||
|
@ -93,7 +108,10 @@ function getAddressedToInfo(input) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { name: input, flavor: MessageConst.AddressFlavor.Local };
|
return {
|
||||||
|
name: input,
|
||||||
|
flavor: MessageConst.AddressFlavor.Local,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let m = input.match(EMAIL_REGEX);
|
let m = input.match(EMAIL_REGEX);
|
||||||
|
@ -107,7 +125,10 @@ function getAddressedToInfo(input) {
|
||||||
|
|
||||||
let addr = Address.fromString(input); // 5D?
|
let addr = Address.fromString(input); // 5D?
|
||||||
if (Address.isValidAddress(addr)) {
|
if (Address.isValidAddress(addr)) {
|
||||||
return { flavor: MessageConst.AddressFlavor.FTN, remote: addr.toString() };
|
return {
|
||||||
|
flavor: MessageConst.AddressFlavor.FTN,
|
||||||
|
remote: addr.toString(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = Address.fromString(input.slice(firstAtPos + 1).trim());
|
addr = Address.fromString(input.slice(firstAtPos + 1).trim());
|
||||||
|
@ -172,6 +193,17 @@ function messageInfoFromAddressedToInfo(addressInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuotePrefixFromName(name) {
|
function getQuotePrefixFromName(name) {
|
||||||
const addrInfo = getAddressedToInfo(name);
|
const addressInfo = getAddressedToInfo(name);
|
||||||
return getQuotePrefix(addrInfo.name || name);
|
return getQuotePrefix(addressInfo.name || name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getReplyToMessagePrefix(name) {
|
||||||
|
const addressInfo = getAddressedToInfo(name);
|
||||||
|
|
||||||
|
// currently only ActivityPub
|
||||||
|
if (addressInfo.flavor === MessageConst.AddressFlavor.ActivityPub) {
|
||||||
|
return `@${addressInfo.name} `;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue