Skip to content

Commit

Permalink
feat: activity type to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
RyoJerryYu committed Jun 13, 2024
1 parent 6eded57 commit 7fedabd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions memos_webhook/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ACTIVITY_TYPE_CREATED = "memos.memo.created"
ACTIVITY_TYPE_UPDATED = "memos.memo.updated"
ACTIVITY_TYPE_DELETED = "memos.memo.deleted"
3 changes: 2 additions & 1 deletion memos_webhook/plugins/base_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import betterproto.lib.google.protobuf as pb

from memos_webhook.constants import ACTIVITY_TYPE_DELETED
from memos_webhook.dependencies.memos_cli import MemosCli
from memos_webhook.proto_gen.memos.api import v1
from memos_webhook.utils.logger import logger
Expand Down Expand Up @@ -149,7 +150,7 @@ async def update_memo_content(
self.logger.info("Plugin task success completed")
assert res_memo is not None, "task should return a memo"

if payload.activity_type == "memos.memo.deleted":
if payload.activity_type == ACTIVITY_TYPE_DELETED:
self.logger.info("Memo deleted, skip update memo content")
return

Expand Down
4 changes: 3 additions & 1 deletion memos_webhook/plugins/you_get_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import aiofiles.os
import betterproto.lib.google.protobuf as pb

from memos_webhook.constants import (ACTIVITY_TYPE_CREATED,
ACTIVITY_TYPE_UPDATED)
from memos_webhook.dependencies.config import YouGetPluginConfig
from memos_webhook.dependencies.memos_cli import MemosCli
from memos_webhook.proto_gen.memos.api import v1
Expand Down Expand Up @@ -35,7 +37,7 @@ def __init__(self, cfg: YouGetPluginConfig) -> None:
self.patterns = [re.compile(pattern) for pattern in cfg.patterns]

def activity_types(self) -> list[str]:
return ["memos.memo.created", "memos.memo.updated"]
return [ACTIVITY_TYPE_CREATED, ACTIVITY_TYPE_UPDATED]

@override
def tag(self) -> str:
Expand Down

0 comments on commit 7fedabd

Please sign in to comment.