Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Webhook #1039

Closed
Zeng1998 opened this issue Feb 7, 2023 · 9 comments
Closed

Support Webhook #1039

Zeng1998 opened this issue Feb 7, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Zeng1998
Copy link
Contributor

Zeng1998 commented Feb 7, 2023

related issues: #418 #676 #961

@Zeng1998 Zeng1998 self-assigned this Feb 7, 2023
@eallion
Copy link
Contributor

eallion commented May 25, 2023

👀

@Zeng1998 Zeng1998 removed their assignment May 26, 2023
@sudoexec
Copy link

Webhook功能还在计划中吗?

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

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

@Issues-translate-bot
Copy link

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.

@tannineo
Copy link

tannineo commented Aug 1, 2023

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

@DengQingNian
Copy link

Webhook功能还在计划中吗?

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

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

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

@Issues-translate-bot
Copy link

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

@sudoexec
Copy link

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

@Issues-translate-bot
Copy link

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.

@sudoexec
Copy link

在官方不支持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
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants