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

julian-klode/mastodon-comments: Mastodon comment server in Go; AGPL licensed

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

开源软件名称(OpenSource Name):

julian-klode/mastodon-comments

开源软件地址(OpenSource Url):

https://github.com/julian-klode/mastodon-comments

开源编程语言(OpenSource Language):

Go 100.0%

开源软件介绍(OpenSource Introduction):

Mastodon comment server

This implements a simple server that finds the first toot mentioning a query and all replies to that toot and returns it as json.

This can be used to embed comments on a blog post: You can post a link to the blog post on your mastodon account, integrate some javascript into your webpage to talk to this server, and all replies to your post announcement toot magically appear on the blog post!

Integration

The server accepts requests in two formats:

  1. The query is passed in a "search" query, for example:

    <url>?search=/path/to/my/blog/post

  2. If a search parameter is not provided, lookup is done based on the path, with the last path element being comments.json, for example:

    /path/to/my/blog/post/comments.json

Configuration

The comment server can only be started using systemd socket activation. The provided systemd units make it listen to the unix domain socket /run/mastodon-comments.sock, on which it will provide fastcgi.

It needs a configuration file as an argument. The configuration file looks like this:

{
        "url": "https://mastodon.social",
        "token": "<your api token here>",
        "userid": "<your user id>", // optional, only look for the root for your account
}

Caching

The server maintains an in-process cache of the root toots. It is advised that you configure your frontend server to cache the results, for example, in nginx:

location ~ ^/2[0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/[^/]+/comments.json$ {
  fastcgi_pass    unix:/run/mastodon-comments.sock;
  include         fastcgi_params;
  fastcgi_cache GO;
  fastcgi_cache_valid 200 10m;
}

The comment server sets a cache-control header to cache found comments for 10 minutes, and no comments for 1 minute, and nginx, if properly configured will respect that.

Status codes

  • 500 is returned if any error occured
  • 200 is returned otherwise, regardless of whether a toot exists or not

To do

  • Keep an on-disk cache of the list of root toots
  • Filter out queries for non-existing posts
  • AppArmor profile



鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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