GithubHelp home page GithubHelp logo

stakwork / sphinx-tribes Goto Github PK

View Code? Open in Web Editor NEW
29.0 9.0 61.0 1.88 GB

Backend for sphinx tribes and bounties. The bounty platform pays out in bitcoin. Sign up with Sphinx Chat, complete a bounty, and earn bitcoin! Go to our website for available bounties.

Home Page: https://community.sphinx.chat/bounties

Go 99.84% Dockerfile 0.07% Procfile 0.01% Shell 0.08%
bitcoin bounty btc foss lightning-network open-source golang

sphinx-tribes's Introduction

Sphinx-Tribes Backend

Tribes

Sphinx-Tribes is a decentralized message broker for public groups within the Sphinx ecosystem. This README covers the setup and configuration of the Sphinx-Tribes backend.

Table of Contents

Prerequisites

  • Docker
  • Go language environment
  • PostgreSQL database
  • Redis instance (optional)
  • Relay server access (optional)

Setup

Cloning the Repository

Clone the Sphinx-Tribes repository:

git clone https://github.com/Vayras/sphinx-tribes.git

Building the Docker Image

Navigate to the cloned directory and build the Docker image:

docker build --no-cache -t sphinx-tribes .
docker tag sphinx-tribes sphinxlightning/sphinx-tribes:x
docker push sphinxlightning/sphinx-tribes:x

Environment Configuration

Create a .env file in the project root with the required environment variables.

Database Setup

Set up a PostgreSQL database and execute the provided SQL scripts to create necessary tables.

Running the Backend

Build and run the Golang backend:

go build .
./sphinx-tribes

Optional Features

Redis for Caching

Configure Redis by adding the REDIS_URL or other relevant variables to your .env file.

    RDS_HOSTNAME =
    RDS_PORT =
    RDS_DB_NAME =
    RDS_USERNAME =
    RDS_PASSWORD =

Relay Integration

For invoice creation and keysend payment, add RELAY_URL and RELAY_AUTH_KEY.

Meme Image Upload

Requires a running Relay. Enable it with MEME_URL.

SuperAdmin Dashboard Access

Add public keys to SUPER_ADMINS in your .env file.

Stakwork YouTube Integration

Add STAKWORK_KEY for YouTube video downloads.

Testing and Mocking

Unit Testing

Run unit tests with coverage:

    // you may need to install cover with this command first
    go get golang.org/x/tools/cmd/cover
    // run test
    RELAY_AUTH_KEY=TEST go test ./... -tags mock -race -v -coverprofile=coverage.out && ./cover-check.sh coverage.out <min coverage amount>
    // To get code coverage in html format do the following after running the code above
    go tool cover -html="coverage.out"

Mocking Interfaces

Use mockery for interface mocking.

Installing mockery

There are multiple options to install mockery. Use any one of the following to download.

Download the mockery binary

Use the release page link mockery releases to download the artifact for your respective device.

Using go install

If you have go already installed on your device you can use the go install command to download mockery.

go install github.com/vektra/mockery/[email protected]
Using homebrew

If you are on mac you can use homebrew to download mockery

brew install mockery
brew upgrade mockery

When adding a new function to the interface which is already mocked follow the below steps

  1. Update the corresponding interface with the function signature, for example if you are adding new function to the database structure make sure the interface file db/interface.go is updated with the function signature.
  2. run the command mockery to update the mocks.

To create mocks for a new interface make follow the steps below

  1. Add the new entry in the .mockery.yml file like this
with-expecter: true
dir: "mocks"
packages:
    github.com/stakwork/sphinx-tribes/db:
        interfaces:
            Database:
    github.com/stakwork/sphinx-tribes/*your-package-name*:
        interfaces:
            *your-interface-1*:
            *your-interface-2*:
  1. run the command mockery to update the mocks.

Backend API Data Validations

We are currently using gopkg.in/go-playground/validator.v9 for validation, to validate a struct add the validate property to it

type Workspace struct {
  Name        string     `gorm:"unique;not null" json:"name" validate:"required"`
  Website     string     `json:"website" validate:"omitempty,uri"`
  Github      string     `json:"github" validate:"omitempty,uri"`
  Description string     `json:"description" validate:"omitempty,lte=200"`
}

Then handle the validation errors in the request handler

err = db.Validate.Struct(org)
if err != nil {
  w.WriteHeader(http.StatusBadRequest)
  msg := fmt.Sprintf("Error: did not pass validation test : %s", err)
  json.NewEncoder(w).Encode(msg)
  return
}

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

License

This project is licensed under the [LICENSE NAME] - see the LICENSE.md file for details.

sphinx-tribes's People

Contributors

abdulwahab3181 avatar aliraza556 avatar amitpaliwal-rs avatar cosmicpotato137 avatar divyank-aggarwal avatar ecurrencyhodler avatar ekep-obasi avatar elraphty avatar evanfeenstra avatar faisaliqbal211 avatar gouravmpk avatar hritikmunde avatar jeezman avatar kevkevinpal avatar khaalid-oh avatar kumarnayan avatar mahtabbukhari avatar manyrios avatar maradondt avatar marvel-ib avatar mirzahanan avatar nebojsatomic avatar plell avatar rassl avatar tobi-bams avatar vayras avatar vishnu552 avatar vividhpandey003 avatar wright-eric avatar yleight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sphinx-tribes's Issues

Profile info improvement

I suggest we group all account related pages (Profile, transactions, Logout) in the dropdown under user name, in the top right corner, and keep left menu reserved for work related items.

image

New RSS episode not showing

Seems like tribes server is caching data or something but new episodes are not coming from tribes server sometimes, even when they are listed in the RSS url.

Example:
RSS feed url: https://feeds.soundcloud.com/users/soundcloud:users:8393376/sounds.rss

Tribes server url: https://tribes.sphinx.chat/podcast?url=https://feeds.soundcloud.com/users/soundcloud:users:8393376/sounds.rss

If it's a cache issue it could be fixed automatically, but right now the last episode (46) shows up on rss, but not on tribes server response.

deeplinks

  • deeplinks to people profiles
  • deeplinks to specific wanted/offers etc within a profile

Add ticket layout problem

The top of the dialogue box gets cut off (including the save button) when adding a ticket.
MacOS, Chrome:

  • sign into people.sphinx.chat
  • "Add ticket"
  • Select type = "Other"
  • Add media, select image

Screen Shot 2022-03-08 at 3 10 38 PM

People page header

We need to add a note saying that the people directory is optional so users don't think they are being added when they start up a sphinx node.

Replace "Discover people on sphinx" with "Add your profile"

/github bot commands

  • get all my tickets
  • view ticket info
  • claim tickets for an amount of time

long term:

  • pay a fee to keep a ticket "claimed" - but it expires after a certain amount of time

Claiming badges on tor

When I tried claiming my sphinx baged to my liquid wallet I came across this error, I'm assuming it's failing because of the tor relay address

Screen Shot 2022-02-08 at 11 12 17 AM

this is the file calling the endpoint ./frontend/app/src/store/main.ts

Should we do something similar to how we do in sphinx-tribes/frontend/app/src/people/main/focusView.tsx where we popup a qr code and then have the user scan it with torSave and submitFormViaApp

Feed content type

We need to add a content feed_type field on tribe model to support listen / watch / read types and any other type we might want to support in the future.

  • Field could be an INT enum so we may need a references table
  • Default to LISTEN type for existing tribes
  • Add param feed_type on POST /tribes
  • Add param feed_type on PUT /tribe?token=
  • Add field on tribe model and table so it's stored there

This way user can set a podcast RSS feed url on Feed Url field, or other types of RSS feed (youtube, newsletters, etc).

Examples:
Video: https://www.youtube.com/feeds/videos.xml?channel_id=UCnCikd0s4i9KoDtaHPlK-JA
Newsletter: https://thesequence.substack.com/feed / https://medium.com/feed/@jjpryor

New tags

Requests from users

  • Sports
  • NSFW

Podcast Index search

We should also move the Podcast Index search to tribes server instead of doing it directly from the app.

GET "\(API.kPodcastIndexURL)/api/1.0/search/byterm"
Param: 
    1. q

Response:

{
    id: Int,
    title: String,
    podcastDescription: String,
    author: String,
    imageURLPath: String?,
    feedURLPath: String?,
}

And then use existing /podcast endpoint to get the detailed information about one specific podcast if user selects it.

auth people with github

  • add a signature into a github gist
  • use github API to pull the gist and verify the signature

badges ui: Counter and duplicate badge design

Badge counter
Some badges will have a counter to indicate its "birth order" (for the lack of a better term). For example, if I have the Early Adopter badge with a counter of "13", that means I am the 13th person to have received that badge.

Duplicate badge ui
There will be badge types that you may hold multiples of that have distinguishing differences. For example, if a badge is rewarded for completing a github issue, there will be users with many github badges. There should be a way to indicate that the badge displayed on the main screen is really a "deck" of badges (like a deck of cards), and clicking it should allow you to see each badge with their distinguishing details - (in the case of a github badge, there will probably be a repository name, and issue number)

Badge status
Badges will have a "pending" status until they are "on-chain" on liquid, which happens when the user clicks a button to put the badge on the liquid chain (this costs some sats)

Paid label and layout fixes

We need a prominent way to tell the user that it is no longer available to work on and it was paid.We want it to be readable if they are interested, but also know right away that it’s no longer available so they don’t waste time and getting their hopes up.

Adding tipping options

  • add field for lightning address (email address for lightning payments)
  • ability to tip a specific blog post
  • the recurring payments link (send tip button on people profile) is showing up blank

Screen Shot 2021-11-02 at 9 09 27 AM

Ticket box borders and shadow

Normal ticket should have no border,
just box-shadow, with values same as on the image below.

Paid ticket should have no box shadow,
just 1 px border, with border color #DDE1E5

image

Missing msgs

It looks like some of the conversation is getting cut off.

IMG_3F3E9ED0A4F6-1

Groups on self hosted nodes

Test on Sphinxtagram group hosted by Klaus

"only admin can post and nobody can join"
"nothing received in the group"

I was able to join previously and see messages from admin. He doesn't see my replies.

Ticket title CSS fix

@plell Hey David, can you please add these few css changes to a ticket tile? Not just color but also font size, style, weight, line height and letter spacing too. Thanks.
image

Feed parsing endpoint

Currently we have one endpoint for podcast:

- GET /podcast
Params: 
     2. url

Hitting it with podcast feed url tribes server will parse xml and return a json with this structure:

 {
	`id` : int,
	`title`: string,
	`url` : string,
	`description` : string,
	`author` : string,
	`image` : string,
	`link` : string,
	`lastUpdateTime` : int / date,
	`contentType` : string,
	`language` : string,
	`episodes`: Array<Episode>,
	`value` : Value
}

Episode: 
{
	`id` : int
	`title` : string,
	`description` : string,
	`datePublished` : int/date,
	`enclosureUrl` : string,
	`enclosureType` : string,
	`enclosureLength` : int,
	`image` : string,
	`link` : string,
}

Value 
{
	`model` : Model,
	`destination` : Array<Destination>,
}

Model 
{
	`type` : string,
	`suggested` : string,
}

Destination 
{
	`address` : string,
	`split` : double,
	`type` : string,
	`customKey` : string,
	`customValue` : string,
}

I would build a new endpoint:

- GET /feed
Params:
    1. tribe_uuid

From the UUID on tribes server we can get the feed_url and the feed_content_type, then request the feed_url, parse the xml depending on the source and return a generic response with all the needed fields no matter the type of the content.

The response would be something like this:

 {
	`id` : string,
        `feedType` : int, (PODCAST / VIDEO / NEWSLETTER)
	`title`: string,
	`url` : string,
	`description` : string,
	`author` : string,
        `generator` : string,
	`imageUrl` : string,
        `ownerUrl` : string,
	`link` : string,
        `datePublished`: int / date,
	`dateUpdated` : int / date,
	`contentType` : string,
	`language` : string,
	`items`: Array<Item>,
	`value` : Value
}

ITEM 
{
	`id` : string
	`title` : string,
	`description` : string,
	`datePublished` : int/date,
        `dateUpdated` : int/date,
        `author` : string,
        `contentType` : string,
	`enclosureUrl` : string,
	`enclosureType` : string,
	`enclosureLength` : int,
	`imageUrl` : string,
        `thumbnailUrl` : string,
	`link` : string,
}

Value 
{
	`model` : Model,
	`destination` : Array<Destination>,
}

Model 
{
	`type` : string,
	`suggested` : string,
}

Destination 
{
	`address` : string,
	`split` : double,
	`type` : string,
	`customKey` : string,
	`customValue` : string,
}

We need to build a json like this from any of this sources and content types. Here are some examples
PODCAST: http://feed.nashownotes.com/rss.xml
NEWSLETTER:
1. Medium: https://medium.com/feed/@jjpryor
2. Substack: https://theborderchronicle.substack.com/feed
VIDEOS:
1. Youtube: https://www.youtube.com/feeds/videos.xml?channel_id=UCnCikd0s4i9KoDtaHPlK-JA
2. Bitcoin TV: https://bitcointv.com/feeds/videos.xml?videoChannelId=2 (this is just something Brian is using to build the generic video player)

Those are the sources we are supporting right now and each one should be handled in a different way to be parsed and return the same json structure to the app. This way if we want to include a new source in the future we just need to handle it on tribes server and app will keep receiving the same.

Roboto font display

Roboto has different font weights (100, 300, 400, 500, 700, 900),
but seems like only two of those can be rendered on our peoples page, i think 300 and 700.
Is there any way we could use all available weights?
Here is link with all samples
https://fonts.google.com/specimen/Roboto

Tribe last activity date

An admin created a new tribe on Jan 20, 2021, the "Last activity" value in the web interface shows Dec 20, 2020.

Screen Shot 2021-01-20 at 9 46 14 AM

github issues bot

  • tribes server can host a "github bot"? that can broadcast into the tribe when a new issue is posted on the people page

Badge Design - 1K, 10K, 1M

We need a vector artwork for three badge/stickers, done in a graffiti style, stylistically matching one of provided samples.
Badges should represent:
1K (one thousand)
10K (ten thousand)
1M ( one million)

Badges should look nice in large scale, but also stay recognizable when scaled down to 40x40px.
Artwork should be vector based, in PDF, SVG or EPS file format.

Style samples:

image

People/tickets page

We need the ability to show which user is working on a particular ticket.
This could be done by adding a field to the ticket record that let's me paste in a pubkey or even better, keyword search the people database and select the developer from the results. That way the person sees visual credit for completing the ticket.

Line breaks

The wanted posts need to show line breaks from the ticket
Screen Shot 2021-10-11 at 2 43 13 PM

Auto show usage/commands for bots

It'd be great to show the usage commands and provide a syntax so bot authors can get them to be parsed and shown in the /help text or on the bots web directory.

Dashboard menu item missing from main menu

In the left menu, we are missing Dashboard.
It should be the first option on the top.
Currently, once I leave the dashboard, I can't find my way back to it.
Click on the logo to go back to dashboard may not be most intuitive solution.

tor support for saving People updates

When a node is behind tor, the people page cannot directly save to relay. Instead, a QR deeplink is shown, so the app can save the data. action=save&host={host}&key={key}

  • Show a "Do you want to save your profile from {host}" message.
  • if user clicks ok:
  • GET https://{host}/save/{key}
// pseudocode
const body = JSON.parse(data.body);
if (data.path === "profile" && data.method === "POST") {
  POST body to relay /profile
} else if (data.path === "profile" && data.method === "DELETE") {
  DELETE relay /profile
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.