@happyvertical/smrt-messages 0.30.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +49 -7
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2 -2
- package/dist/models/Message.d.ts +10 -0
- package/dist/models/Message.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +4 -4
- package/dist/svelte/components/AccountAvatar.svelte +4 -4
- package/dist/svelte/components/AccountList.svelte +12 -3
- package/dist/svelte/components/AccountList.svelte.d.ts.map +1 -1
- package/dist/svelte/components/ComposeForm.svelte +27 -2
- package/dist/svelte/components/ComposeForm.svelte.d.ts.map +1 -1
- package/dist/svelte/components/EmailAccountManager.svelte +25 -2
- package/dist/svelte/components/EmailAccountManager.svelte.d.ts.map +1 -1
- package/dist/svelte/components/EmailFilterManager.svelte +50 -2
- package/dist/svelte/components/EmailFilterManager.svelte.d.ts.map +1 -1
- package/dist/svelte/components/ForwardForm.svelte +26 -2
- package/dist/svelte/components/ForwardForm.svelte.d.ts.map +1 -1
- package/dist/svelte/components/MessageDetail.svelte +11 -14
- package/dist/svelte/components/MessageDetail.svelte.d.ts.map +1 -1
- package/dist/svelte/components/ReplyForm.svelte +26 -2
- package/dist/svelte/components/ReplyForm.svelte.d.ts.map +1 -1
- package/dist/svelte/components/SendStatusBadge.svelte +1 -1
- package/dist/svelte/components/ThreadView.svelte +10 -3
- package/dist/svelte/components/ThreadView.svelte.d.ts.map +1 -1
- package/dist/svelte/i18n.d.ts +2 -0
- package/dist/svelte/i18n.d.ts.map +1 -1
- package/dist/svelte/i18n.js +2 -0
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -673,6 +673,13 @@ let Message = class extends SmrtObject {
|
|
|
673
673
|
* Send this message via its account's sender
|
|
674
674
|
*/
|
|
675
675
|
async send(options) {
|
|
676
|
+
if (this.sendStatus === "sending" || this.sendStatus === "sent") {
|
|
677
|
+
return {
|
|
678
|
+
success: false,
|
|
679
|
+
error: `Cannot send: message is already '${this.sendStatus}'`,
|
|
680
|
+
sentAt: /* @__PURE__ */ new Date()
|
|
681
|
+
};
|
|
682
|
+
}
|
|
676
683
|
const account = await this.getAccount();
|
|
677
684
|
if (!account) {
|
|
678
685
|
const result = {
|
|
@@ -687,9 +694,27 @@ let Message = class extends SmrtObject {
|
|
|
687
694
|
return result;
|
|
688
695
|
}
|
|
689
696
|
const sender = await account.createSender();
|
|
690
|
-
this.sendStatus
|
|
691
|
-
this.
|
|
692
|
-
|
|
697
|
+
const claimFromStatus = this.sendStatus;
|
|
698
|
+
if (this.isPersisted && this.id) {
|
|
699
|
+
const claim = await this.db.update(
|
|
700
|
+
this.tableName,
|
|
701
|
+
{ id: this.id, send_status: claimFromStatus },
|
|
702
|
+
{ send_status: "sending", updated_at: /* @__PURE__ */ new Date() }
|
|
703
|
+
);
|
|
704
|
+
if (!claim || claim.affected < 1) {
|
|
705
|
+
return {
|
|
706
|
+
success: false,
|
|
707
|
+
error: "Cannot send: message is already being sent",
|
|
708
|
+
sentAt: /* @__PURE__ */ new Date()
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
this.sendStatus = "sending";
|
|
712
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
713
|
+
} else {
|
|
714
|
+
this.sendStatus = "sending";
|
|
715
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
716
|
+
await this.save();
|
|
717
|
+
}
|
|
693
718
|
try {
|
|
694
719
|
const result = await sender.send(this, options);
|
|
695
720
|
if (result.success) {
|
|
@@ -739,12 +764,29 @@ let Message = class extends SmrtObject {
|
|
|
739
764
|
await this.save();
|
|
740
765
|
return this.send(options);
|
|
741
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Options for a derived draft (reply/forward) built from this message. Carries
|
|
769
|
+
* the DB connection + tenant context from `this.options`, but strips this
|
|
770
|
+
* message's own identity fields. When this message was hydrated from the DB,
|
|
771
|
+
* `this.options` holds the row's `id`/`slug`/`context`/`_skipLoad`; spreading
|
|
772
|
+
* those into a new draft would make `draft.save()` upsert onto the natural-key
|
|
773
|
+
* conflict columns (`slug`/`context`/`_meta_type`) and overwrite the ORIGINAL
|
|
774
|
+
* message instead of inserting a new row. See EmailAccount.childOptions().
|
|
775
|
+
*/
|
|
776
|
+
draftOptions() {
|
|
777
|
+
const rest = { ...this.options };
|
|
778
|
+
delete rest.id;
|
|
779
|
+
delete rest.slug;
|
|
780
|
+
delete rest.context;
|
|
781
|
+
delete rest._skipLoad;
|
|
782
|
+
return rest;
|
|
783
|
+
}
|
|
742
784
|
/**
|
|
743
785
|
* Create a reply to this message (returns unsaved draft)
|
|
744
786
|
*/
|
|
745
787
|
createReply(_options) {
|
|
746
788
|
const reply = new this.constructor({
|
|
747
|
-
...this.
|
|
789
|
+
...this.draftOptions(),
|
|
748
790
|
id: void 0,
|
|
749
791
|
accountId: this.accountId,
|
|
750
792
|
threadId: this.threadId || this.id || "",
|
|
@@ -769,7 +811,7 @@ let Message = class extends SmrtObject {
|
|
|
769
811
|
*/
|
|
770
812
|
createForward() {
|
|
771
813
|
const forward = new this.constructor({
|
|
772
|
-
...this.
|
|
814
|
+
...this.draftOptions(),
|
|
773
815
|
id: void 0,
|
|
774
816
|
accountId: this.accountId,
|
|
775
817
|
threadId: "",
|
|
@@ -1776,7 +1818,7 @@ let Email = class extends Message {
|
|
|
1776
1818
|
*/
|
|
1777
1819
|
createReply(options) {
|
|
1778
1820
|
const reply = new Email({
|
|
1779
|
-
...this.
|
|
1821
|
+
...this.draftOptions(),
|
|
1780
1822
|
id: void 0,
|
|
1781
1823
|
accountId: this.accountId,
|
|
1782
1824
|
threadId: this.threadId || this.id || void 0,
|
|
@@ -1826,7 +1868,7 @@ let Email = class extends Message {
|
|
|
1826
1868
|
createForward() {
|
|
1827
1869
|
const forwardBody = this.buildForwardBody();
|
|
1828
1870
|
const forward = new Email({
|
|
1829
|
-
...this.
|
|
1871
|
+
...this.draftOptions(),
|
|
1830
1872
|
id: void 0,
|
|
1831
1873
|
accountId: this.accountId,
|
|
1832
1874
|
threadId: "",
|