mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-19 11:43:35 +00:00
Add topics database table
This commit is contained in:
parent
f019b64695
commit
8573140134
@ -209,6 +209,7 @@ export const contacts = new Table("contacts", "pubkey")
|
|||||||
export const rooms = new Table("rooms", "id")
|
export const rooms = new Table("rooms", "id")
|
||||||
export const relays = new Table("relays", "url")
|
export const relays = new Table("relays", "url")
|
||||||
export const routes = new Table("routes", "id", {max: 3000, sort: sortByLastSeen})
|
export const routes = new Table("routes", "id", {max: 3000, sort: sortByLastSeen})
|
||||||
|
export const topics = new Table("topics", "name")
|
||||||
|
|
||||||
export const getPersonWithFallback = pubkey => people.get(pubkey) || {pubkey}
|
export const getPersonWithFallback = pubkey => people.get(pubkey) || {pubkey}
|
||||||
export const getRelayWithFallback = url => relays.get(url) || {url}
|
export const getRelayWithFallback = url => relays.get(url) || {url}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {uniq, pick, identity} from "ramda"
|
import {uniq, nth, objOf, pick, identity} from "ramda"
|
||||||
import {nip05} from "nostr-tools"
|
import {nip05} from "nostr-tools"
|
||||||
import {noop, ensurePlural, chunk} from "hurdak/lib/hurdak"
|
import {noop, ensurePlural, chunk} from "hurdak/lib/hurdak"
|
||||||
import {
|
import {
|
||||||
@ -13,7 +13,7 @@ import {
|
|||||||
hash,
|
hash,
|
||||||
} from "src/util/misc"
|
} from "src/util/misc"
|
||||||
import {Tags, roomAttrs, isRelay, isShareableRelay, normalizeRelayUrl} from "src/util/nostr"
|
import {Tags, roomAttrs, isRelay, isShareableRelay, normalizeRelayUrl} from "src/util/nostr"
|
||||||
import {people, userEvents, relays, rooms, routes} from "src/agent/db"
|
import {topics, people, userEvents, relays, rooms, routes} from "src/agent/db"
|
||||||
import {uniqByUrl} from "src/agent/relays"
|
import {uniqByUrl} from "src/agent/relays"
|
||||||
import user from "src/agent/user"
|
import user from "src/agent/user"
|
||||||
|
|
||||||
@ -341,4 +341,17 @@ addHandler(10002, e => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Topics
|
||||||
|
|
||||||
|
const processTopics = e => {
|
||||||
|
const matches = Array.from(e.content.matchAll(/#(\w{2,100})/g))
|
||||||
|
|
||||||
|
if (matches.length > 0) {
|
||||||
|
topics.patch(matches.map(nth(1)).map(objOf("name")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addHandler(1, processTopics)
|
||||||
|
addHandler(42, processTopics)
|
||||||
|
|
||||||
export default {processEvents}
|
export default {processEvents}
|
||||||
|
Loading…
Reference in New Issue
Block a user