@@ -21,6 +22,13 @@
+
+ 인스타 DM 문구
+ [DM 보내기]를 누르면 복사되는 글 — 비워 두면 메일 본문 + 끝 문구가 그대로 복사됩니다
+
@@ -56,4 +64,4 @@
{% endblock %}
-{% block scripts %}{% endblock %}
+{% block scripts %}{% endblock %}
diff --git a/app/static/outreach.css b/app/static/outreach.css
index 91ae217..972b808 100644
--- a/app/static/outreach.css
+++ b/app/static/outreach.css
@@ -66,6 +66,9 @@
.otr-field { display: flex; flex-direction: column; gap: 4px; }
.otr-field .erp-input { width: 100%; min-width: 0; box-sizing: border-box; }
.otr-body { font-size: 14px; line-height: 1.6; resize: vertical; }
+.otr-tpl-sub { margin: 10px 0 0; padding-top: 14px; border-top: 1px solid var(--color-subtle-ash, #e5e5e5); }
+.otr-count { align-self: flex-end; font-size: 12px; }
+.otr-count.is-over { color: #c0392b; }
.otr-check { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.otr-set-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.otr-images { display: flex; gap: 12px; flex-wrap: wrap; }
diff --git a/app/static/outreach.js b/app/static/outreach.js
index 355b935..632e6fc 100644
--- a/app/static/outreach.js
+++ b/app/static/outreach.js
@@ -1,6 +1,7 @@
/* 안내문 발송(2026-10-27) — 리스트 화면: 붙여 넣기 → 미리보기(메일/DM/오류) → 추가, 걸러 보기, 이름 고치기,
메일 = 고른 줄 [고른 메일 보내기](서버가 본인 Gmail 로 한 통씩, 보내는 동안 2초마다 다시 읽음),
- DM = [DM 보내기](그 사람 이름이 들어간 문구를 클립보드에 + ig.me DM 창을 새 탭) → [보냄]. 설정 화면 = [기본 문구로 되돌리기]. */
+ DM = [DM 보내기](그 사람 이름이 들어간 문구를 클립보드에 + ig.me DM 창을 새 탭) → [보냄].
+ 설정 화면 = [기본 문구로 되돌리기], DM 문구 글자 수. */
(function () {
"use strict";
@@ -43,15 +44,26 @@
defBtn.addEventListener("click", function () {
let d = {};
try { d = JSON.parse(document.getElementById("otr-default-data").textContent); } catch (_) { d = {}; }
- if (!confirm("제목·본문·보내는 이름·끝 문구를 기본 문구로 바꿀까요? ([저장]을 눌러야 적용)")) return;
+ if (!confirm("제목·본문·보내는 이름·끝 문구·DM 문구를 기본 문구로 바꿀까요? ([저장]을 눌러야 적용)")) return;
const f = document.getElementById("otr-set-form");
f.subject.value = d.subject || "";
f.body.value = d.body || "";
f.sender_name.value = d.sender_name || "";
f.footer.value = d.footer || "";
+ f.dm_body.value = d.dm_body || "";
f.ad_label.checked = !!d.ad_label;
+ dmCount();
});
}
+ // DM 문구 글자 수(인스타 DM 한 통 한도) — 비어 있으면 메일 본문으로 간다는 안내
+ const dmBody = document.getElementById("otr-dm-body"), dmCountEl = document.getElementById("otr-dm-count");
+ function dmCount() {
+ if (!dmBody || !dmCountEl) return;
+ const n = dmBody.value.length, max = Number(dmCountEl.dataset.max) || 1000;
+ dmCountEl.textContent = n ? n + " / " + max + "자" : "비어 있음 — 메일 본문 + 끝 문구가 복사됩니다";
+ dmCountEl.classList.toggle("is-over", n >= max);
+ }
+ if (dmBody) { dmBody.addEventListener("input", dmCount); dmCount(); }
// ── 리스트 화면 ──
const root = document.getElementById("otr");
@@ -153,7 +165,7 @@
const r = rowOf(btn);
if (!r) return;
if (btn.dataset.act === "dm") {
- if (r.needs_name) { toast("이름을 먼저 넣으세요 — 본문에 {이름}이 있습니다.", true); return; }
+ if (r.needs_name) { toast("이름을 먼저 넣으세요 — DM 문구에 {이름}이 있습니다.", true); return; }
// 누르는 순간 바로(브라우저가 막지 않게) — 문구 복사 + DM 창 새 탭. 문구는 화면 데이터에 미리 있다.
const win = window.open(r.dm_link, "_blank", "noopener");
const ok = await copyText(r.dm_text || "");
diff --git a/tests/test_outreach.py b/tests/test_outreach.py
index 11dded6..819aeef 100644
--- a/tests/test_outreach.py
+++ b/tests/test_outreach.py
@@ -69,6 +69,20 @@ class RenderTests(unittest.TestCase):
self.assertEqual(h.count('src="cid:'), 2)
self.assertEqual(store.dm_link("mira.kitchen"), "https://ig.me/m/mira.kitchen")
+ def test_dm_body(self):
+ # DM 문구가 비면 메일 글(본문 + 끝 문구), 있으면 그것만 — 별표만 빼고 {이름}, 끝 문구·제목 없이
+ self.assertEqual(store.dm_text(self.T, "김철수"), store.plain_text(self.T, "김철수"))
+ self.assertEqual(store.DEFAULT_TEMPLATE["dm_body"], "")
+ t = store.normalize_template({**self.T, "dm_body": " {이름}님, **미라네주방**입니다!\r\n메일 주소 알려주세요 "})
+ self.assertEqual(store.dm_text(t, "미라"), "미라님, 미라네주방입니다!\n메일 주소 알려주세요")
+ self.assertEqual(len(store.normalize_template({"dm_body": "가" * 5000})["dm_body"]), store.DM_MAX)
+ # 이름 필요 = 그 구분으로 갈 글 기준
+ no_name_dm = store.normalize_template({"subject": "{이름}님", "body": "{이름}", "dm_body": "안녕하세요"})
+ self.assertTrue(store.needs_name(no_name_dm, "email"))
+ self.assertFalse(store.needs_name(no_name_dm, "instagram"))
+ self.assertTrue(store.needs_name(t, "instagram"))
+ self.assertTrue(store.needs_name(store.normalize_template({"body": "x", "footer": "{이름}"}), "instagram"))
+
class FakeDB:
def __init__(self, template=None, images=()):
@@ -296,6 +310,16 @@ def body(c):
assert pv["subject"] == "(광고) 김철수님 제안" and "안녕하세요 김철수님" in pv["html"] and "수신 거부: 회신" in pv["text"]
# 이름 고치기
assert c.put(f"/outreach/api/recipients/{nobody['id']}", json={"name": "노바디"}).json()["row"]["needs_name"] is False
+ # 인스타 DM 문구 — 저장하면 DM 줄 글·미리보기가 그 문구로(메일은 그대로)
+ assert "인스타 DM 문구" in s and 'name="dm_body"' in s
+ r = c.post("/outreach/settings", data={"subject": "{이름}님 제안", "body": "안녕하세요 {이름}님", "footer": "수신 거부: 회신",
+ "dm_body": "{이름}님, **DM** 문구입니다"})
+ assert r.status_code == 303 and st.t["dm_body"] == "{이름}님, **DM** 문구입니다"
+ mira2 = next(x for x in c.get("/outreach/api/recipients").json()["rows"] if x["id"] == mira["id"])
+ assert mira2["dm_text"] == "미라님, DM 문구입니다", mira2
+ assert c.get(f"/outreach/api/recipients/{mira['id']}/preview").json()["text"] == "미라님, DM 문구입니다"
+ assert "수신 거부: 회신" in c.get(f"/outreach/api/recipients/{kim['id']}/preview").json()["text"]
+ assert "**DM** 문구입니다" in c.get("/outreach/settings").text
# 메일 보내기 — Gmail 없음 = 409(재연결 안내)
r = c.post("/outreach/api/send", json={"ids": [kim["id"]]})
assert r.status_code == 409 and r.json()["reconnect"] is True
@@ -416,8 +440,10 @@ class OutreachDBTests(unittest.TestCase):
st = self.st
t = st.get_template()
self.assertTrue(t["subject"])
- saved = st.save_template({"subject": "제목 {이름}", "body": "본문", "ad_label": True, "sender_name": "미라네"}, by="Me@X.com")
+ saved = st.save_template({"subject": "제목 {이름}", "body": "본문", "ad_label": True, "sender_name": "미라네",
+ "dm_body": "{이름}님 DM"}, by="Me@X.com")
self.assertEqual((saved["subject"], saved["ad_label"], saved["updated_by"], saved["is_default"]), ("제목 {이름}", True, "me@x.com", False))
+ self.assertEqual(st.get_template()["dm_body"], "{이름}님 DM")
with self.assertRaises(ValueError):
st.save_template({"subject": "", "body": "x"}, by="me")
ids = [st.add_image(filename=f"{i}.jpg", data=b"\xff\xd8" + bytes([i]), width=10, height=10, by="me") for i in range(2)]