Don't append channel to non-root posts
Problem: When publishing a root post, other clients give you the option of adding a `channel` property, which is basically just a hashtag. We show this at the end of the message, but since replies often copy the `channel` property then it gets appended to every reply. Solution: Only append the channel as a hashtag for root posts.
This commit is contained in:
parent
42e051fc6a
commit
1adbd15afd
@ -469,10 +469,17 @@ module.exports = ({ cooler, isPublic }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const isPost =
|
||||
lodash.get(msg, "value.content.type") === "post" &&
|
||||
lodash.get(msg, "value.content.text", false) !== false;
|
||||
const hasRoot = lodash.get(msg, "value.content.root", false) !== false;
|
||||
const hasFork = lodash.get(msg, "value.content.fork", false) !== false;
|
||||
|
||||
const channel = lodash.get(msg, "value.content.channel");
|
||||
const hasChannel = typeof channel === "string" && channel.length > 2;
|
||||
const isRoot = hasRoot === false;
|
||||
|
||||
if (hasChannel) {
|
||||
if (hasChannel && isRoot) {
|
||||
msg.value.content.text += `\n\n#${channel}`;
|
||||
}
|
||||
|
||||
@ -506,12 +513,6 @@ module.exports = ({ cooler, isPublic }) => {
|
||||
url: avatarUrl,
|
||||
});
|
||||
|
||||
const isPost =
|
||||
lodash.get(msg, "value.content.type") === "post" &&
|
||||
lodash.get(msg, "value.content.text") != null;
|
||||
const hasRoot = lodash.get(msg, "value.content.root") != null;
|
||||
const hasFork = lodash.get(msg, "value.content.fork") != null;
|
||||
|
||||
if (isPost && hasRoot === false && hasFork === false) {
|
||||
lodash.set(msg, "value.meta.postType", "post");
|
||||
} else if (isPost && hasRoot && hasFork === false) {
|
||||
|
11
src/ssb.js
11
src/ssb.js
@ -77,7 +77,7 @@ const createConnection = (config) => {
|
||||
lodash.get(ssbConfig, "friends.hops", 0)
|
||||
);
|
||||
|
||||
const add = address => {
|
||||
const add = (address) => {
|
||||
inProgress[address] = true;
|
||||
return () => {
|
||||
inProgress[address] = false;
|
||||
@ -88,10 +88,10 @@ const createConnection = (config) => {
|
||||
rawConnect()
|
||||
.then((ssb) => {
|
||||
log("Retrying connection to own server");
|
||||
ssb.friends.hops().then(hops => {
|
||||
ssb.friends.hops().then((hops) => {
|
||||
pull(
|
||||
ssb.conn.stagedPeers(),
|
||||
pull.drain(x => {
|
||||
pull.drain((x) => {
|
||||
x.filter(([address, data]) => {
|
||||
const notInProgress = inProgress[address] !== true;
|
||||
|
||||
@ -110,10 +110,7 @@ const createConnection = (config) => {
|
||||
hops[data.key]
|
||||
}/${maxHops} hops: ${address}`
|
||||
);
|
||||
ssb.conn
|
||||
.connect(address, data)
|
||||
.then(done)
|
||||
.catch(done);
|
||||
ssb.conn.connect(address, data).then(done).catch(done);
|
||||
});
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user