MCPcopy
hub / github.com/kickscondor/fraidycat / subscribe

Function subscribe

src/js/storage.js:892–923  ·  view source on GitHub ↗
(fc, sender)

Source from the content-addressed store, hash-verified

890 // Subscribe to (possibly) several from a list of feeds for a site.
891 //
892 async subscribe(fc, sender) {
893 // console.log(fc)
894 let site = fc.site, list = fc.list, follows = []
895 let sel = list.filter(feed => feed.selected), errors = []
896 for (let feed of sel) {
897 let follow = {url: feed.url, importance: site.importance,
898 tags: site.tags, title: site.title, editedAt: new Date()}
899 if (sel.length > 1) {
900 follow.title = `${followTitle(site)} [${feed.title}]`
901 }
902
903 try {
904 let feeds = await this.refresh(follow, 0)
905 if (feeds) {
906 errors.push(`${follow.url} is not a feed.`)
907 } else {
908 follows.push(follow.id)
909 }
910 } catch (msg) {
911 if (msg.message)
912 msg = msg.message
913 errors.push(msg)
914 }
915 }
916 if (follows.length > 0)
917 this.write({update: true, follows})
918 if (errors.length > 0) {
919 this.update({op: 'error', message: errors.join("\n")}, sender)
920 } else {
921 this.update({op: 'subscription', follow: site}, sender)
922 }
923 },
924
925 //
926 // Write the master list (and the sync list, possibly) to disk.

Callers

nothing calls this directly

Calls 2

followTitleFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected