• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

tateisu/mastodon-streaming-listener: This is a server to provide relay the notif ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

tateisu/mastodon-streaming-listener

开源软件地址(OpenSource Url):

https://github.com/tateisu/mastodon-streaming-listener

开源编程语言(OpenSource Language):

JavaScript 98.3%

开源软件介绍(OpenSource Introduction):

mastodon-streaming-listener

This is a server to provide relay the notification from Mastodon's Streaming API to registered callback URL.

slide1

Different things from Tusky-api.

  • Separate streaming listener server and application server.
  • Streaming listener server does not have application specific information. There is a possibility that it can correspond to multiple applications.
  • Possible to replace the Streaming API URL to inside the LAN
  • (It focus to make Streaming listener server by instance-owner)
  • Since the application server does not handle WebSocket, it becomes easy to scale.
  • Both the streaming listener server and the application server can be configured behaviors for each instance.
  • Support only for a specific instance

API

POST /register

(parameters)

  • instance_url : URL of Mastodon instance you want to listen. ex) https://mastodon.juggler.jp . max length is 255 byte.
  • tag : any String that can be used for management in your app. this is also used for a part of unique key of registrations. max length is 255 byte.
  • app_id: ID of the your app. max length is 255 byte.
  • app_secret : Secret of the your app.
  • access_token : The access token you get from Mastodon's oAuth API.
  • callback_url : The URL that will be called when new notification is arrived.
  • endpoint : (optional)Type of streaming endpoint. One of 'user', 'user:notification'. If this parameter is not specified, default value is ( mastodon instance version >= v1.4.2 ? 'user:notification' : 'user' ).

(notice) Your app needs to call /register repeatly within 3 days to keep listening.

POST /unregister

(parameters)

  • instance_url : same of specified in /register.
  • tag : same of specified in /register.
  • app_id : same of specified in /register.
  • app_secret : secret of the your app.

(notice) The unique key of listener registration is : instanceUrl + appId + tag. If you want to certainly unregister registration, You have to make same these parameters.

Callback

Callback is called with POST method. Request body is Content-Type 'application/json' and it has following data.

  • instanceUrl : same of specified in /register.
  • tag : same of specified in /register.
  • appId : same of specified in /register.
  • payload : see document of Mastodon's Streaming API.

installation (using docker-compose)

prepare database

Please make a database for this app. and memo the parameters that required to connect from app to database.

# type of db. One of mysql, postgres, mssql. (Don't use sqlite)
DB_DIALECT=postgres

# host name or IP addres of database server
DB_HOST=172.17.0.1

# port number of database server
DB_PORT=4003

# name of database
DB_NAME=streaming_listener

# login information
DB_USER=streaming_listener
DB_PASS=***

edit configuration files

after git clone , you have to change some file.

# copy sample configuration files
cp config/app_map.hjson.sample config/app_map.hjson
cp config/instance_map.hjson.sample config/instance_map.hjson

(edit these .hjson files to configure for client app and instances)

cp .env.production.sample .env.production

(edit this .env file to configure database connection.)

build and start

docker-compose build

docker-compose up

configure nginx

This app listens on port 4002 at default. You can configure exposed port in docker-compose.yml. You should use Web frontend (nginx) to wrap with HTTPS.

Tweak

create index

create unique index stream_listener_registrations_iat on stream_listener_registrations ( "instanceUrl","appId","tag" );




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap