diff --git a/art/themes/luciano_blocktronics/activitypub_social_manager.ans b/art/themes/luciano_blocktronics/activitypub_social_manager.ans index 56af586e..c5fd35d6 100644 Binary files a/art/themes/luciano_blocktronics/activitypub_social_manager.ans and b/art/themes/luciano_blocktronics/activitypub_social_manager.ans differ diff --git a/art/themes/luciano_blocktronics/theme.hjson b/art/themes/luciano_blocktronics/theme.hjson index f1af5eb9..e3946ceb 100644 --- a/art/themes/luciano_blocktronics/theme.hjson +++ b/art/themes/luciano_blocktronics/theme.hjson @@ -486,7 +486,7 @@ activityPubFollowingManager: { config: { - selectedActorInfoFormat: "|00|15{preferredUsername}\n|02{name}\n{summary}" + selectedActorInfoFormat: "|00|15{preferredUsername}\n|02{name}\n{plainTextSummary}" statusIndicatorEnabled: "|00|10√" staticIndicatorDisabled: "|00|12X" } @@ -500,7 +500,7 @@ } MT2: { height: 15 - width: 32 + width: 38 } TM3: { focusTextStyle: first upper diff --git a/core/activitypub/social_manager.js b/core/activitypub/social_manager.js index 588fe3bf..bd7ddfe1 100644 --- a/core/activitypub/social_manager.js +++ b/core/activitypub/social_manager.js @@ -13,6 +13,7 @@ const { Collections } = require('./const'); // deps const async = require('async'); const { get, cloneDeep } = require('lodash'); +const { htmlToMessageBody } = require('./util'); exports.moduleInfo = { name: 'ActivityPub Social Manager', @@ -122,8 +123,13 @@ exports.getModule = class ActivityPubFollowingManager extends MenuModule { return callback(err); } - this.followingActors = followingActors; - this.followerActors = followerActors; + const mapper = a => { + a.plainTextSummary = htmlToMessageBody(a.summary); + return a; + }; + + this.followingActors = followingActors.map(mapper); + this.followerActors = followerActors.map(mapper); return callback(null); } @@ -212,7 +218,11 @@ exports.getModule = class ActivityPubFollowingManager extends MenuModule { const s = stringFormat(selectedActorInfoFormat, actorInfo); if (view instanceof MultiLineEditTextView) { - view.setAnsi(pipeToAnsi(s, this.client)); + const opts = { + prepped: false, + forceLineTerm: true, + }; + view.setAnsi(pipeToAnsi(s, this.client), opts); } else { view.setText(s); } @@ -282,6 +292,7 @@ exports.getModule = class ActivityPubFollowingManager extends MenuModule { delete actor.text; delete actor.status; delete actor.statusIndicator; + delete actor.plainTextSummary; return actor; } @@ -306,6 +317,9 @@ exports.getModule = class ActivityPubFollowingManager extends MenuModule { selectedActorType: v('type'), selectedActorName: v('name'), selectedActorSummary: v('summary'), + selectedActorPlainTextSummary: actorInfo + ? htmlToMessageBody(actorInfo.summary || '') + : '', selectedActorPreferredUsername: v('preferredUsername'), selectedActorUrl: v('url'), selectedActorImage: v('image'), diff --git a/core/activitypub/util.js b/core/activitypub/util.js index 34d6ea40..0f6564bb 100644 --- a/core/activitypub/util.js +++ b/core/activitypub/util.js @@ -13,9 +13,9 @@ const waterfall = require('async/waterfall'); const fs = require('graceful-fs'); const paths = require('path'); const moment = require('moment'); -const { striptags } = require('striptags'); const { encode, decode } = require('html-entities'); const { isString } = require('lodash'); +const { stripHtml } = require('string-strip-html'); exports.parseTimestampOrNow = parseTimestampOrNow; exports.isValidLink = isValidLink; @@ -217,10 +217,8 @@ function messageToHtml(message) { } function htmlToMessageBody(html) { - //
,
, and
,
-> \r\n - //

-> \r\n - html = html.replace(/(?:<\/?br ?\/?>)|(?:<\/p>)/g, '\r\n'); - return striptags(decode(html)); + const res = stripHtml(decode(html)); + return res.result; } function userNameFromSubject(subject) { diff --git a/core/servers/content/web.js b/core/servers/content/web.js index 92a38dbb..3062689c 100644 --- a/core/servers/content/web.js +++ b/core/servers/content/web.js @@ -149,9 +149,12 @@ exports.getModule = class WebServerModule extends ServerModule { createServer(cb) { if (this.enableHttp) { - this.httpServer = http.createServer((req, resp) => - this.routeRequest(req, resp) - ); + this.httpServer = http.createServer((req, resp) => { + resp.on('error', err => { + this.log.error({ error: err.message }, 'Response error'); + }); + this.routeRequest(req, resp); + }); } const config = Config(); diff --git a/package.json b/package.json index 490c9397..fc84926c 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ ], "dependencies": { "@breejs/later": "4.1.0", + "add": "^2.0.6", "async": "3.2.4", "avatar-generator": "^2.0.4", "binary-parser": "2.1.0", @@ -64,13 +65,14 @@ "sqlite3": "5.0.11", "sqlite3-trans": "1.3.0", "ssh2": "1.11.0", - "striptags": "^4.0.0-alpha.4", + "string-strip-html": "8.4.0", "systeminformation": "5.12.3", "telnet-socket": "0.2.4", "temptmp": "^1.1.0", "uuid": "8.3.2", "uuid-parse": "1.1.0", "ws": "7.5.9", + "yarn": "^1.22.19", "yazl": "^2.5.1" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 53cf5057..344836b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -131,6 +131,11 @@ acorn@^8.8.0: resolved "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz" integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA== +add@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/add/-/add-2.0.6.tgz#248f0a9f6e5a528ef2295dbeec30532130ae2235" + integrity sha512-j5QzrmsokwWWp6kUcJQySpbG+xfOBqqKnup3OIk1pz+kB/80SLorZ9V8zHFLO92Lcd+hbvq8bT+zOGoPkmBV0Q== + agent-base@6, agent-base@^6.0.2: version "6.0.2" resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz" @@ -2598,6 +2603,11 @@ string-argv@^0.3.1: resolved "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz" integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== +string-strip-html@8.4.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/string-strip-html/-/string-strip-html-8.4.0.tgz#3baf7fc56ef566393077a6941e8ba13c91b43d0b" + integrity sha512-ajjEpk0V1G0+/RrX08I2pSj/kfsYU5wkUKWEKPQJXVQpdahZNSljiuWVqf8UgrB2E9DvFcougbl1gPwHzkuEDg== + string-width@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -2680,11 +2690,6 @@ strip-json-comments@~2.0.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ== -striptags@^4.0.0-alpha.4: - version "4.0.0-alpha.4" - resolved "https://registry.yarnpkg.com/striptags/-/striptags-4.0.0-alpha.4.tgz#824f1ac040f824574316ce87a3663c0c4df9900d" - integrity sha512-/0jWyVWhpg9ciRHfjKYBpMHXct/HrFRfsR2HU77nGPbc8SPcVSIHZlZR/0TG3MyPq2C+HiHuwx8BlbcdI/cNbw== - supports-color@^7.1.0: version "7.1.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz" @@ -3005,6 +3010,11 @@ yaml@^2.1.3: resolved "https://registry.npmjs.org/yaml/-/yaml-2.2.1.tgz" integrity sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw== +yarn@^1.22.19: + version "1.22.19" + resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.19.tgz#4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" + integrity sha512-/0V5q0WbslqnwP91tirOvldvYISzaqhClxzyUKXYxs07yUILIs5jx/k6CFe8bvKSkds5w+eiOqta39Wk3WxdcQ== + yazl@^2.5.1: version "2.5.1" resolved "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz"