memos icon indicating copy to clipboard operation
memos copied to clipboard

Support Webhook

Open Zeng1998 opened this issue 2 years ago • 1 comments

related issues: #418 #676 #961

Zeng1998 avatar Feb 07 '23 06:02 Zeng1998

👀

eallion avatar May 25 '23 18:05 eallion

Webhook功能还在计划中吗?

目前想把Memos做为主要的写作平台,然后利用Webhook同步到微博,Twitter和Telegram等社交媒体。

现在的API勉强也能做增量同步,但是要不断轮询,才能实现实时同步,不太合理。

sudoexec avatar Jul 24 '23 07:07 sudoexec

Issue is not in English. It has been translated automatically.


Is the webhook feature still planned?

At present, I want to use Memos as the main writing platform, and then use Webhook to synchronize to social media such as Weibo, Twitter, and Telegram.

The current API can barely do incremental synchronization, but continuous polling is required to achieve real-time synchronization, which is unreasonable.

Issues-translate-bot avatar Jul 24 '23 07:07 Issues-translate-bot

Any updates to this feature? Is someone working or planing on this?

tannineo avatar Aug 01 '23 15:08 tannineo

Webhook功能还在计划中吗?

目前想把Memos做为主要的写作平台,然后利用Webhook同步到微博,Twitter和Telegram等社交媒体。

现在的API勉强也能做增量同步,但是要不断轮询,才能实现实时同步,不太合理。

我fork了个加上了memo增删改的hook自己用,不用你能不能用的上--> memos

DengQingNian avatar Sep 14 '23 07:09 DengQingNian

Issue is not in English. It has been translated automatically.


Is Webhook functionality still planned?

Currently I want to use Memos as the main writing platform, and then use Webhook to synchronize to social media such as Weibo, Twitter and Telegram.

The current API can barely do incremental synchronization, but it requires constant polling to achieve real-time synchronization, which is not reasonable.

I forked a hook with memo additions, deletions and modifications for my own use. Can you use it without it? --> memos

Issues-translate-bot avatar Sep 14 '23 07:09 Issues-translate-bot

@RustyNailPlease 多谢大佬。不过我有很多Self-Hosted应用,运维负担很重,所以不想再用第三方的fork了。

sudoexec avatar Sep 14 '23 08:09 sudoexec

Issue is not in English. It has been translated automatically.


@RustyNailPlease Thanks man. However, I have many Self-Hosted applications and the operation and maintenance burden is heavy, so I no longer want to use third-party forks.

Issues-translate-bot avatar Sep 14 '23 08:09 Issues-translate-bot

在官方不支持Webhook的情况下,又不想单独维护一个Fork,想到了另外一种解决方案:在服务端做手脚。

Memos一般都是部署在反向代理后面的,而我前不久刚刚切换了OpenResty,可以在OpenResty中用Lua获取请求数据,然后发送一个HTTP请求。

代码如下:

        access_by_lua_block {
            local json = require("cjson")
            local http = require("resty.http")
            
            local uri = ngx.var.request_uri
            local method = ngx.req.get_method()

            if uri == "/api/v1/memo" and method == "POST" then
                ngx.req.read_body()
                local memo = json.decode(ngx.req.get_body_data())
                if memo.visibility == "PUBLIC" then
                    local webhook_data = { type = "memos", data = memo }
                    -- modify your webhook url here
                    local webhook_url = ""
                    local http_client = http.new()
                    local res, err = http_client:request_uri(webhook_url, {
                        method = "POST",
                        headers = {
                            ["Content-Type"] = "application/json",
                        },
                        body = json.encode(webhook_data)
                    })
                    if not res then
                        ngx.log(ngx.ERR,err)
                    end
                end
            end
        }

sudoexec avatar Sep 15 '23 10:09 sudoexec