{
  "name": "misskey to memos",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "3b8dde97-50c8-4a94-bc8f-522323de007d",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -440,
        20
      ],
      "id": "63f9835f-ee32-4e13-89e5-4e9ca7ce7f6b",
      "name": "Webhook",
      "webhookId": "3b8dde97-50c8-4a94-bc8f-522323de007d"
    },
    {
      "parameters": {
        "jsCode": "// 获取第一个输入项的数据\nconst inputItem = $input.first();\n\n// 从输入 JSON 中提取数据\nconst jsonString = inputItem.json; // 直接使用json属性\n\n// 注意，这里多了一个 'body' 层级\nconst bodyData = jsonString.body?.body;\n\nif (!bodyData || !bodyData.note) {\n    // 如果没有找到 note 数据，返回 null 或抛出错误\n    return null;\n}\n\n// 提取相关的 ID\nconst reply_id = bodyData.note.reply?.userId;\nconst note_id = bodyData.note.userId;\n\nlet requestBody = null;\n\n// 判断 reply_id 是否为 null 或与 note_id 相同\nif (!reply_id || reply_id === note_id) {\n    // 提取文本\n    const text = bodyData.note.text || '';\n\n    // 提取图片链接，如果 files 未定义，则使用空数组\n    const imageLinks = (bodyData.note.files || [])\n        .filter(file => file.type && file.type.startsWith(\"image\"))\n        .map(file => `![image](${file.url})`)\n        .join(\"\\n\");\n\n    // 构建内容\n    const content = `#misskey\\n${text}\\n${imageLinks}`.trim();\n\n    // 构建请求体\n    requestBody = {\n        content: content,\n        visibility: \"PUBLIC\"\n    };\n}\n\n// 返回构建好的请求体 JSON (如果没有满足条件就返回null)\nreturn requestBody;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -220,
        20
      ],
      "id": "0d624892-e28a-492d-a594-6c17e8c99729",
      "name": "Code"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://me.lehhair.net/api/v1/memo",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "Bearer eyJh"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "=content",
              "value": "={{ $json.content }}"
            },
            {
              "name": "visibility",
              "value": "={{ $json.visibility }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        20
      ],
      "id": "552ed75e-3370-4173-bf18-0dd11a43ff76",
      "name": "HTTP Request"
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0a8100ba-26e2-46f2-824b-5a332524efdb",
  "meta": {
    "instanceId": "59b6a3dd0019155293f3369a94b9b87ddc8c2c18ad1f0c7d963d05f87cfed75b"
  },
  "id": "67aFT43Y7KNwT3Cy",
  "tags": []
}