diff --git a/app/modules/outreach/CLAUDE.md b/app/modules/outreach/CLAUDE.md index e6a831d..c591ba9 100644 --- a/app/modules/outreach/CLAUDE.md +++ b/app/modules/outreach/CLAUDE.md @@ -21,6 +21,11 @@ - **인스타 DM = 반자동** — 인스타 공식 API 는 처음 연락하는 사람에게 DM 을 보낼 수 없다(상대가 먼저 보낸 24시간 안만, 자동 DM 은 약관 위반·계정 정지 위험). [DM 보내기] = 그 사람 이름이 든 문구 복사 + `https://ig.me/m/계정` 새 탭(누르는 순간 — 문구는 리스트 데이터에 미리 담음) → 붙여 넣어 보낸 뒤 [보냄](`dm-sent`, 기록). **DM 문구** = 설정 `dm_body`(글, `store.dm_text`, 최대 1000자 `DM_MAX`, `{이름}`, 별표만 뺌) — 비어 있으면 메일 본문 글 + 끝 문구. "이름 필요"도 구분별(`needs_name(t, kind)`). +- **DM 수동 보내기**(2026-10-30, 리스트 화면 [+ 리스트 추가] 오른쪽) — 이름만 붙여 넣기·파일(.txt·.csv 첫 칸, 머리글 "이름"·빈 줄·같은 이름 뺌) + → 왼쪽 이름 목록, 누르면 오른쪽 DM 문구의 `{이름}` 이 그 이름으로 바뀌고 바로 클립보드 복사 + 짧은 안내(1.6초). 문구 = 설정 DM 문구 + (`dm_template` = `store.dm_text(template, NAME_TAG)`, 리스트 줄 [DM 보내기]와 같은 글). 브라우저만 — 리스트에 저장하지 않음. xlsx 는 이름 칸 복사해 붙여 넣기. +- 설정 = 위 막대 맨 오른쪽 톱니(`.otr-gear`, 공용 `vendor/material-symbols`). `.otr .erp-card[hidden]` — 공용 `.erp-card` display:flex 가 hidden 을 덮어 + [리스트 추가] 창이 늘 열려 있던 것 고침(2026-10-30). - **설정** `/outreach/settings`(모듈 권한자 누구나) — **세로 2단**: 왼쪽 메일(제목·"(광고)"·보내는 이름·본문 서식 편집기·끝 문구·본문 아래 사진), 오른쪽 인스타 DM(서식 없는 편집기·글자 수·[메일 본문 글 가져오기]), 위 막대 [저장]·[기본 문구로 되돌리기](칸만, 저장해야 적용) — 1100px 아래는 위아래. 입력 칸은 `form="otr-set-form"` 으로 위 막대 폼에 묶음(사진 폼과 겹치지 않게). 편집기 = Quill snow(글자 크기 px·굵게·기울임·밑줄·취소선·글자/배경 색·정렬·목록·링크·서식 지우기·되돌리기), diff --git a/app/modules/outreach/router.py b/app/modules/outreach/router.py index 47839a3..03adf0f 100644 --- a/app/modules/outreach/router.py +++ b/app/modules/outreach/router.py @@ -135,6 +135,8 @@ def index(request: Request) -> Any: "page_title": "안내문 발송", "page_subtitle": "메일 일괄 발송 · 인스타 DM", "template": template, "body_text": store.html_to_text(template["body"]), "needs_name": store.needs_name(template), "images": st.list_images(), "rows": rows, "logs": st.list_logs(limit=50), + # DM 수동 보내기 — {이름} 을 그대로 둔 DM 문구(화면이 고른 이름으로 바꿔 복사) + "dm_template": store.dm_text(template, store.NAME_TAG), "gmail": _gmail_state(request, user), "msg": request.query_params.get("msg", ""), }) diff --git a/app/modules/outreach/templates/outreach/index.html b/app/modules/outreach/templates/outreach/index.html index 09c6888..cb00bb9 100644 --- a/app/modules/outreach/templates/outreach/index.html +++ b/app/modules/outreach/templates/outreach/index.html @@ -2,7 +2,8 @@ {#- 안내문 발송(2026-10-27) — 리스트(주소 + 이름) → 메일은 [선택한 메일 보내기](본인 Gmail, 한 사람에 한 통), 인스타는 [DM 보내기](문구 복사 + DM 창) → 보낸 뒤 [보냄]. 주소를 보고 메일/DM 을 정한다(store.detect). 본문 {이름} = 그 줄 이름. -#} -{% block head_extra %}{% endblock %} +{% block head_extra %} +{% endblock %} {% block content %}
@@ -10,7 +11,7 @@
- 설정 +
{% if gmail.connected %} @@ -24,6 +25,9 @@ Gmail 연결을 쓸 수 없는 서버입니다(입출고 DB·구글 OAuth·APP_ENCRYPTION_KEY 필요) — 메일은 보낼 수 없고 DM 만 됩니다. {% endif %}
+ {#- 설정 = 맨 오른쪽 톱니(2026-10-30, 실적·프로젝트와 같은 아이콘) -#} + +
{% if msg %}

{{ msg }}

{% endif %} @@ -50,6 +54,27 @@ + {#- DM 수동 보내기(2026-10-30) — 이름만 붙여 넣기·파일(.txt·.csv) → 왼쪽 이름 목록, 누르면 오른쪽 DM 문구의 {이름} 이 그 이름으로 바뀌고 + 바로 클립보드에 복사(리스트에 저장하지 않음, 문구 = 설정의 DM 문구 — 리스트 줄의 [DM 보내기]와 같은 글) -#} + +
{% for key, label in (('all', '전체'), ('email', '메일'), ('instagram', 'DM'), ('대기', '대기'), ('보냄', '보냄'), ('실패', '실패')) %} @@ -96,7 +121,7 @@
- + {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/outreach/templates/outreach/settings.html b/app/modules/outreach/templates/outreach/settings.html index 107bae9..275ac7c 100644 --- a/app/modules/outreach/templates/outreach/settings.html +++ b/app/modules/outreach/templates/outreach/settings.html @@ -5,7 +5,7 @@ 편집기 = Quill(/static/vendor/quill). 입력 칸은 form="otr-set-form" 으로 위 막대의 저장 폼에 묶는다(사진 폼과 겹치지 않게). -#} {% block head_extra %} - + {% endblock %} {% block content %} @@ -89,5 +89,5 @@ {% block scripts %} - + {% endblock %} diff --git a/app/static/outreach.css b/app/static/outreach.css index 18e35f2..58bbab0 100644 --- a/app/static/outreach.css +++ b/app/static/outreach.css @@ -2,7 +2,13 @@ .erp-page:has(> .otr) { box-sizing: border-box; } /* 셸 .erp-page width:100% + 여백 → 오른쪽 넘침 방지(실적·휴가와 같음) */ .otr { display: flex; flex-direction: column; gap: 14px; } .otr > * { flex-shrink: 0; } -.otr-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; } +.otr-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; } +.otr-top .otr-gmail { margin-left: auto; } +/* 설정 톱니 — 맨 오른쪽(2026-10-30, 실적 .perf-tab-gear 와 같은 모양) */ +.otr-gear { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; + color: var(--color-midtone-gray, #6d6e6f); text-decoration: none; flex: none; } +.otr-gear .material-symbols-outlined { font-size: 22px; } +.otr-gear:hover { color: var(--color-rich-black, #1e1f21); background: var(--color-ghost-gray, #f3f3f3); } .otr-top-main { display: flex; gap: 8px; } .otr-gmail { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; } .otr-gmail form { margin: 0; } @@ -10,6 +16,7 @@ .otr-gmail-off { color: #8a5a00; } .otr-msg { margin: 0; padding: 8px 12px; border-radius: 8px; background: #eef6ff; color: #1a4fa0; font-size: 13px; } .otr .erp-card { padding: 14px 16px; } +.otr .erp-card[hidden] { display: none; } /* 공용 .erp-card display:flex 가 hidden 을 덮어 [리스트 추가]·DM 수동 창이 늘 열려 있었다 */ .otr-tpl-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: 14px; flex-wrap: wrap; } .otr-tpl-head .erp-muted { font-size: 12px; } .otr-tpl-subject { font-weight: 700; font-size: 15px; } @@ -114,3 +121,17 @@ .otr-image-acts form { margin: 0; } .otr-upload { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; } .otr .erp-btn:disabled { opacity: .45; cursor: default; } + +/* DM 수동 보내기(2026-10-30) — 왼쪽 이름 목록 | 오른쪽 이름이 들어간 DM 문구(이름 누르면 복사) */ +.otr-dm-file { cursor: pointer; } +.otr-dm-split { display: grid; grid-template-columns: minmax(160px, 240px) minmax(0, 1fr); gap: 12px; margin-top: 12px; } +.otr-dm-names { list-style: none; margin: 0; padding: 4px; border: 1px solid #e3e5e8; border-radius: 8px; max-height: 420px; overflow: auto; } +.otr-dm-name { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: 13px; + padding: 6px 10px; border-radius: 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.otr-dm-name:hover { background: #f3f4f6; } +.otr-dm-name.is-active { background: #111; color: #fff; } +.otr-dm-empty { padding: 8px 10px; font-size: 13px; } +.otr-dm-body { border: 1px solid #e3e5e8; border-radius: 8px; padding: 12px 14px; font-size: 13.5px; line-height: 1.6; + white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; background: #fafafa; } +.otr-dm-body b { color: #c1358a; } +@media (max-width: 640px) { .otr-dm-split { grid-template-columns: 1fr; } } diff --git a/app/static/outreach.js b/app/static/outreach.js index d2b4bdc..618b97b 100644 --- a/app/static/outreach.js +++ b/app/static/outreach.js @@ -18,14 +18,14 @@ if (!res.ok) { const e = new Error(data.message || data.detail || ("HTTP " + res.status)); e.status = res.status; e.data = data; throw e; } return data; } - function toast(msg, bad) { + function toast(msg, bad, ms) { let el = document.getElementById("otr-toast"); if (!el) { el = document.createElement("div"); el.id = "otr-toast"; el.className = "otr-toast"; document.body.appendChild(el); } el.textContent = msg; el.classList.toggle("is-bad", !!bad); el.hidden = false; clearTimeout(el._t); - el._t = setTimeout(function () { el.hidden = true; }, 4000); + el._t = setTimeout(function () { el.hidden = true; }, ms || 4000); } async function copyText(text) { try { await navigator.clipboard.writeText(text); return true; } catch (_) { /* 아래로 */ } @@ -368,5 +368,62 @@ } catch (err) { addSave.disabled = false; toast("추가 실패: " + err.message, true); } }); + // DM 수동 보내기(2026-10-30) — 이름만 넣어(붙여 넣기·.txt/.csv) 왼쪽 목록, 이름을 누르면 오른쪽 DM 문구의 {이름} 을 바꾸고 바로 복사. + // 문구 = 설정 DM 문구({이름} 그대로, 서버 store.dm_text). 리스트에는 저장하지 않는다(이 화면을 떠나면 사라짐). + const dmBox = document.getElementById("otr-dm"), dmText = document.getElementById("otr-dm-text"); + const dmNames = document.getElementById("otr-dm-names"), dmBody = document.getElementById("otr-dm-body"); + let dmTemplate = ""; + try { dmTemplate = JSON.parse(document.getElementById("otr-data").textContent).dm_template || ""; } catch (_) { dmTemplate = ""; } + let dmList = [], dmPick = -1; + // 줄마다 첫 칸(탭·쉼표 앞) = 이름, 빈 줄·머리글("이름")·같은 이름은 뺀다 + function parseNames(text) { + const out = []; + String(text || "").split(/\r?\n/).forEach(function (line) { + const n = line.split(/[\t,]/)[0].replace(/^["']|["']$/g, "").trim(); + if (n && n !== "이름" && out.indexOf(n) < 0) out.push(n); + }); + return out; + } + function renderDm() { + dmNames.innerHTML = dmList.length + ? dmList.map(function (n, i) { + return '
  • "; + }).join("") + : '
  • 이름을 넣으면 여기에 나옵니다.
  • '; + const name = dmPick >= 0 ? dmList[dmPick] : ""; + // 문구 — 고른 이름은 굵게(화면만), 안 골랐으면 {이름} 그대로 + dmBody.innerHTML = dmTemplate.split("{이름}").map(esc).join(name ? "" + esc(name) + "" : "{이름}"); + document.getElementById("otr-dm-sum").textContent = dmList.length ? dmList.length + "명" : ""; + } + function loadNames(text) { + dmList = parseNames(text); + dmPick = -1; + renderDm(); + if (!dmList.length) toast("넣을 이름이 없습니다.", true); + } + document.getElementById("otr-dm-open").addEventListener("click", function () { + dmBox.hidden = false; + renderDm(); + dmText.focus(); + if (!dmTemplate.trim()) toast("DM 문구가 비었습니다 — 설정에서 DM 문구를 넣으세요.", true); + }); + document.getElementById("otr-dm-close").addEventListener("click", function () { dmBox.hidden = true; }); + document.getElementById("otr-dm-load").addEventListener("click", function () { loadNames(dmText.value); }); + document.getElementById("otr-dm-file").addEventListener("change", async function (e) { + const f = e.target.files && e.target.files[0]; + if (!f) return; + try { dmText.value = await f.text(); loadNames(dmText.value); } catch (err) { toast("파일을 읽지 못했습니다: " + err.message, true); } + e.target.value = ""; + }); + dmNames.addEventListener("click", async function (e) { + const b = e.target.closest(".otr-dm-name"); + if (!b) return; + dmPick = +b.dataset.i; + renderDm(); + const name = dmList[dmPick]; + const ok = await copyText(dmTemplate.split("{이름}").join(name)); + toast(ok ? name + " 님 문구를 클립보드에 복사했습니다." : "복사하지 못했습니다 — 오른쪽 글을 직접 복사하세요.", !ok, 1600); + }); + render(); })(); diff --git a/tests/js/outreach.browser.test.js b/tests/js/outreach.browser.test.js index ee31649..c1515a1 100644 --- a/tests/js/outreach.browser.test.js +++ b/tests/js/outreach.browser.test.js @@ -120,6 +120,32 @@ function check(name, cond, extra) { await p.waitForTimeout(200); const sendCall = calls.find(function (c) { return c.url === "/outreach/api/send"; }); check("고른 메일 보내기 → 메일·대기 줄만 보냄", !!sendCall && JSON.stringify(sendCall.body.ids) === "[1,3]", sendCall); + // 설정 = 맨 오른쪽 톱니 아이콘(2026-10-30) + const gear = await p.evaluate(function () { + const g = document.querySelector(".otr-gear"), top = document.querySelector(".otr-top").getBoundingClientRect(), r = g.getBoundingClientRect(); + return { href: g.getAttribute("href"), icon: g.textContent.trim(), right: Math.round(top.right - r.right), + font: getComputedStyle(g.querySelector(".material-symbols-outlined")).fontFamily }; + }); + check("설정 = 맨 오른쪽 톱니(글자 대신 아이콘)", gear.href === "/outreach/settings" && gear.icon === "settings" && gear.right <= 2 && + /Material Symbols/.test(gear.font), gear); + // DM 수동 보내기 — 이름 넣기 → 왼쪽 목록, 이름 누르면 오른쪽 문구 {이름} 바뀌고 복사 + 짧은 안내 + await p.click("#otr-dm-open"); + await p.fill("#otr-dm-text", "이름\n김민지\t메모\n\n박서준, x\n김민지"); + await p.click("#otr-dm-load"); + const names = await p.$$eval("#otr-dm-names .otr-dm-name", function (els) { return els.map(function (e) { return e.textContent; }); }); + check("DM 수동 — 이름 목록(첫 칸, 머리글·빈 줄·같은 이름 뺌)", JSON.stringify(names) === '["김민지","박서준"]', names); + await p.click('#otr-dm-names .otr-dm-name[data-i="1"]'); + await p.waitForTimeout(100); + const dm = await p.evaluate(async function () { + const t = document.getElementById("otr-toast"); + return { body: document.getElementById("otr-dm-body").textContent, clip: navigator.clipboard ? await navigator.clipboard.readText() : (window.__copied || ""), + toast: t && !t.hidden ? t.textContent : "", active: document.querySelector(".otr-dm-name.is-active").textContent }; + }); + check("이름 누르면 오른쪽 문구 = 그 이름, 클립보드 복사, 안내", dm.active === "박서준" && dm.body.includes("박서준") && !dm.body.includes("{이름}") && + dm.clip === dm.body && /박서준 님 문구를 클립보드에 복사/.test(dm.toast), dm); + await p.waitForTimeout(1800); + check("안내는 잠깐 뒤 사라짐", await p.evaluate(function () { return document.getElementById("otr-toast").hidden; })); + await p.click("#otr-dm-close"); // 리스트 추가 — 미리보기(판별) → 추가 await p.click("#otr-add-open"); await p.fill("#otr-add-text", "new@x.com 새사람\n@hong 홍\n홍길동"); diff --git a/tests/js/render_outreach.py b/tests/js/render_outreach.py index 42a9e96..fb5fa9f 100644 --- a/tests/js/render_outreach.py +++ b/tests/js/render_outreach.py @@ -36,6 +36,7 @@ def main() -> None: ctx = {"user": {"email": "me@miras.co.kr", "name": "나", "picture": ""}, "is_admin": False, "nav_items": [], "page_title": "안내문 발송", "page_subtitle": "", "template": t, "body_text": store.html_to_text(t["body"]), "needs_name": store.needs_name(t), "images": [], "rows": [_view(r, t) for r in raw], + "dm_template": store.dm_text(t, store.NAME_TAG), "logs": [], "gmail": {"available": True, "connected": True, "email": "me@miras.co.kr"}, "msg": ""} with open(os.path.join(OUT_DIR, "outreach.html"), "w", encoding="utf-8") as f: f.write(env.get_template("outreach/index.html").render(**ctx))