git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 217c274425bfc6f97a221190b58a329730ab0482

make channels/hashtags case insensitive (uses ssb-ref normalizeChannel)

Matt McKegg committed on 11/20/2017, 3:31:45 AM
Parent: ab49d98e85de76db59f84cc035e271040023fad3

Files changed

lib/normalize-channel.jsdeleted
modules/page/html/render/channel.jschanged
modules/page/html/render/public.jschanged
package.jsonchanged
sbot/channels.jschanged
sbot/roots.jschanged
sbot/subscriptions.jschanged
lib/normalize-channel.jsView
@@ -1,8 +1,0 @@
1-module.exports = function (channel) {
2- if (typeof channel === 'string') {
3- channel = channel.replace(/\s/g, '')
4- if (channel.length > 0 && channel.length < 30) {
5- return channel
6- }
7- }
8-}
modules/page/html/render/channel.jsView
@@ -3,8 +3,9 @@
33
44 exports.needs = nest({
55 'channel.obs.subscribed': 'first',
66 'message.html.compose': 'first',
7+ 'channel.sync.normalize': 'first',
78 'feed.html.rollup': 'first',
89 'feed.pull.channel': 'first',
910 'sbot.pull.log': 'first',
1011 'message.async.publish': 'first',
@@ -18,9 +19,9 @@
1819 const i18n = api.intl.sync.i18n
1920 return nest('page.html.render', function channel (path) {
2021 if (path[0] !== '#') return
2122
22- var channel = path.substr(1)
23+ var channel = api.channel.sync.normalize(path.substr(1))
2324 var subscribedChannels = api.channel.obs.subscribed(api.keys.sync.id())
2425
2526 var prepend = [
2627 h('PageHeading', [
@@ -53,12 +54,12 @@
5354
5455 function mentionFilter (msg) {
5556 // filter out likes
5657 if (msg.value.content.type === 'vote') return false
57- if (msg.value.content.channel === channel) return true
58+ if (api.channel.sync.normalize(msg.value.content.channel) === channel) return true
5859 if (Array.isArray(msg.value.content.mentions)) {
5960 if (msg.value.content.mentions.some(mention => {
60- return mention && mention.link === `#${channel}`
61+ return mention && api.channel.sync.normalize(mention.link) === `#${channel}`
6162 })) {
6263 return 'channel-mention'
6364 }
6465 }
modules/page/html/render/public.jsView
@@ -1,8 +1,7 @@
11 var nest = require('depnest')
22 var extend = require('xtend')
33 var pull = require('pull-stream')
4-var normalizeChannel = require('../../../../lib/normalize-channel')
54 var { h, send, when, computed, map } = require('mutant')
65
76 exports.needs = nest({
87 sbot: {
@@ -29,8 +28,9 @@
2928 'channel.obs': {
3029 subscribed: 'first',
3130 recent: 'first'
3231 },
32+ 'channel.sync.normalize': 'first',
3333 'keys.sync.id': 'first',
3434 'settings.obs.get': 'first',
3535 'intl.sync.i18n': 'first'
3636 })
@@ -88,9 +88,9 @@
8888 var type = msg.value.content.type
8989 if (type === 'vote') return false
9090
9191 var author = msg.value.author
92- var channel = normalizeChannel(msg.value.content.channel)
92+ var channel = api.channel.sync.normalize(msg.value.content.channel)
9393 var tagged = checkTag(msg.value.content.mentions)
9494 var isSubscribed = channel ? subscribedChannels().has(channel) : false
9595 return isSubscribed || id === author || following().includes(author) || tagged
9696 }
@@ -138,9 +138,9 @@
138138 function checkTag (mentions) {
139139 if (Array.isArray(mentions)) {
140140 return mentions.some((mention) => {
141141 if (mention && typeof mention.link === 'string' && mention.link.startsWith('#')) {
142- var channel = normalizeChannel(mention.link.slice(1))
142+ var channel = api.channel.sync.normalize(mention.link.slice(1))
143143 return channel ? subscribedChannels().has(channel) : false
144144 }
145145 })
146146 }
package.jsonView
@@ -41,9 +41,9 @@
4141 "mutant": "^3.21.2",
4242 "mutant-pull-reduce": "^1.1.0",
4343 "obv": "0.0.1",
4444 "patch-settings": "^1.0.1",
45- "patchcore": "~1.16.0",
45+ "patchcore": "~1.17.0",
4646 "pull-abortable": "^4.1.0",
4747 "pull-defer": "^0.2.2",
4848 "pull-file": "~1.0.0",
4949 "pull-identify-filetype": "^1.1.0",
@@ -57,17 +57,17 @@
5757 "sorted-array-functions": "~1.0.0",
5858 "spacetime": "^1.0.7",
5959 "ssb-about": "~0.1.1",
6060 "ssb-avatar": "^0.2.0",
61- "ssb-backlinks": "~0.4.1",
61+ "ssb-backlinks": "~0.5.0",
6262 "ssb-blobs": "~1.1.4",
6363 "ssb-friends": "^2.3.5",
6464 "ssb-keys": "^7.0.13",
6565 "ssb-mentions": "^0.4.0",
6666 "ssb-msgs": "^5.2.0",
6767 "ssb-private": "0.1.4",
6868 "ssb-query": "^1.0.0",
69- "ssb-ref": "~2.7.1",
69+ "ssb-ref": "^2.8.0",
7070 "ssb-sort": "^1.0.0",
7171 "statistics": "^3.3.0",
7272 "suggest-box": "^2.2.3",
7373 "text-node-searcher": "^1.1.1"
sbot/channels.jsView
@@ -1,6 +1,6 @@
11 var FlumeReduce = require('flumeview-reduce')
2-var normalizeChannel = require('../lib/normalize-channel')
2+var normalizeChannel = require('ssb-ref').normalizeChannel
33
44 module.exports = function (ssb, config) {
55 return ssb._flumeUse('patchwork-channels', FlumeReduce(1, reduce, map))
66 }
sbot/roots.jsView
@@ -3,9 +3,9 @@
33 var FlumeViewLevel = require('flumeview-level')
44 var pullCat = require('pull-cat')
55 var HLRU = require('hashlru')
66 var extend = require('xtend')
7-var normalizeChannel = require('../lib/normalize-channel')
7+var normalizeChannel = require('ssb-ref').normalizeChannel
88 var Defer = require('pull-defer')
99
1010 // HACK: pull it out of patchcore
1111 var getRoot = require('patchcore/message/sync/root').create().message.sync.root
sbot/subscriptions.jsView
@@ -1,6 +1,6 @@
11 var FlumeReduce = require('flumeview-reduce')
2-var normalizeChannel = require('../lib/normalize-channel')
2+var normalizeChannel = require('ssb-ref').normalizeChannel
33
44 module.exports = function (ssb, config) {
55 return ssb._flumeUse('patchwork-subscriptions', FlumeReduce(3, reduce, map))
66 }

Built with git-ssb-web