Skip to main content

通过接口解决Soapbox前端远程实例unpin失效问题

·1195 字·3 分钟
Pleroma Soapbox
目录

1. 问题说明

Soapbox的前端页面在查看某个远程实例时,可以将实例pin为按钮固定展示。但当这类按钮固定满3个后,无法取消固定,unpin按钮失效了。

于是我每次切换到“联邦宇宙/跨站公共时间轴”时,就不得不面对这闹心的按钮……

2. 查找方法

去soapbox的论坛里找了找,发现已经有人提了 bug,只是一直没解决。

往下翻评论

@tassoman:

The button triggers XHR OPTIONS /api/v1/accounts/update_credentials [HTTP/2 204 No Content 48ms] XHR PATCH /api/v1/accounts/update_credentials

Flawless with no errors. But server’s user store can’t be updated/modified. Should have removed an item from the array.

  "remote_timeline": {
    "pinnedHosts": [
      "misskey.social"
    ]
  }

灵光一闪,或许可以直接修改接口来解决?

先去 soapbox 文档 查了评论里提及的接口/api/v1/accounts/update_credentials ,摘录如下。

PATCH /api/v1/accounts/update_credentials

…… All images (avatar, banner and background) can be reset to the default by sending an empty string ("") instead of a file.

  • 所有图片(头像、横幅和背景)都可以通过发送空字符串("")而不是文件来重置为默认值。

Pleroma Settings Store

Pleroma has mechanism that allows frontends to save blobs of json for each user on the backend. This can be used to save frontend-specific settings for a user that the backend does not need to know about.

The parameter should have a form of {frontend_name: {…}}, with frontend_name identifying your type of client, e.g. pleroma_fe. It will overwrite everything under this property, but will not overwrite other frontend’s settings.

  • 参数应采用 {frontend_name: {…}} 的形式,其中 frontend_name 标识您的客户端类型,例如 pleroma_fe。它将覆盖此属性下的所有内容,但不会覆盖其他前端的设置。

This information is returned in the /api/v1/accounts/verify_credentials endpoint.

上面提及到pleroma的前端设置属性可以使用参数进行修改。

pleroma接口文档中查对应接口。

3. 动手解决

因为之前有在用postman做一些接口测试,这次就直接打开。下载安装注册之类的不赘述了。

3.1 获取访问令牌

调取接口需要拿到登录用户的oAuth访问令牌,通过浏览器的开发者工具来获取。

在实例登录页面,通过按键F12打开开发者工具,清空之前的网络请求。输入账号密码后点击登录。

网络(Network)中找到名为token的请求,点击打开,在响应中找到access_token字段,复制对应值(不带引号),即为访问令牌。

具体如下图


3.2 新建请求,验证各项无误

在postman中新建请求,按以下步骤填写好各项内容

① 请求方式选择 PATCH

② 填写api地址,注意将{{url}}替换为实例链接(带https://

③ 令牌类型选择bearer token

④ 将前面f12获取的访问令牌填写入内


点击发送(send),接口返回的信息会出现在下方响应body中。

ctrl+F 搜索关键词 soapbox_fe (最好对soapbox_fe下的内容复制保留……),即可看到当前对soapbox前端的一些设置,其中就可以看到这次要解决的问题。

"remote_timeline": {
    "pinnedHosts": [
        domain1,
        domain2,
        domain3
    ]
}

3.3 填写参数更新属性

postman切换到请求body内,按下图选择参数形式,填写对应内容,最后选择发送。

ps. 图片内的body内容(即④处),由于省略了其他属性值,会把对soapbox_fe的已有设置清空。建议保留上一步的查询结果,在此基础上进行修改。

{
    "pleroma_settings_store": {
        "soapbox_fe": {
            "remote_timeline": {
                "pinnedHosts": []
            }
        }
    }
}

OK了,去实例中刷新页面,烦人的按钮消失了。

好耶。

👏👏👏 鼓掌 👏👏👏