Phase 10, part 7: posting accounts, and who may post to which
Social accounts become posting accounts: several per network, the company's and each person's own, with their tokens kept per account. The old sign-ins are adopted as the company's. Admins say who may post to which (Settings → Posting accounts); a draft can go out from one account or a copy to several, each recording who posted it and as what. Signing an account out, or removing its owner, holds the posts scheduled to it and tells whoever scheduled them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -132,13 +132,13 @@ func TestDraftsAndPublish(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
// LinkedIn isn't connected: refused, and nothing changes.
|
||||
pub := &fakePub{}
|
||||
if _, err := Publish(ctx, d, Publishers{ChannelX: pub}, nil, li.ID); err == nil || !strings.Contains(err.Error(), "isn't connected") {
|
||||
if _, err := Publish(ctx, d, ChannelPublishers{ChannelX: pub}, nil, li.ID); err == nil || !strings.Contains(err.Error(), "isn't connected") {
|
||||
t.Errorf("publishing without a connection: %v", err)
|
||||
}
|
||||
|
||||
// A failure is recorded; the draft can be fixed and published again.
|
||||
pub.err = errors.New("HTTP 503")
|
||||
if _, err := Publish(ctx, d, Publishers{ChannelX: pub}, nil, x.ID); err == nil {
|
||||
if _, err := Publish(ctx, d, ChannelPublishers{ChannelX: pub}, nil, x.ID); err == nil {
|
||||
t.Fatal("expected the failure")
|
||||
}
|
||||
got, _ := GetDraft(d, x.ID)
|
||||
@@ -149,7 +149,7 @@ func TestDraftsAndPublish(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pub.err = nil
|
||||
got, err = Publish(ctx, d, Publishers{ChannelX: pub}, nil, x.ID)
|
||||
got, err = Publish(ctx, d, ChannelPublishers{ChannelX: pub}, nil, x.ID)
|
||||
if err != nil || got.Status != StatusPublished || got.PostURL == "" || got.Error != "" {
|
||||
t.Fatalf("publish: %+v, %v", got, err)
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func TestDraftsAndPublish(t *testing.T) {
|
||||
t.Errorf("published %q", last)
|
||||
}
|
||||
// Published once: a second click doesn't post again, and it can't be edited.
|
||||
if _, err := Publish(ctx, d, Publishers{ChannelX: pub}, nil, x.ID); !errors.Is(err, ErrBusy) {
|
||||
if _, err := Publish(ctx, d, ChannelPublishers{ChannelX: pub}, nil, x.ID); !errors.Is(err, ErrBusy) {
|
||||
t.Errorf("second publish: %v", err)
|
||||
}
|
||||
if err := UpdateDraft(d, x.ID, "again"); !errors.Is(err, ErrNotEditable) {
|
||||
@@ -170,7 +170,7 @@ func TestDraftsAndPublish(t *testing.T) {
|
||||
// Too long for X: refused before calling X.
|
||||
_, _ = CreateDrafts(d, []Draft{{Channel: ChannelX, Content: strings.Repeat("a", 270), SourceURL: "https://example.com"}})
|
||||
long, _ := ListDrafts(d, 1, StatusDraft)
|
||||
if _, err := Publish(ctx, d, Publishers{ChannelX: pub}, nil, long[0].ID); err == nil || !strings.Contains(err.Error(), "295 characters including the link") {
|
||||
if _, err := Publish(ctx, d, ChannelPublishers{ChannelX: pub}, nil, long[0].ID); err == nil || !strings.Contains(err.Error(), "295 characters including the link") {
|
||||
t.Errorf("over-long post: %v", err)
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ func TestScheduleAndDue(t *testing.T) {
|
||||
// Publishing tags only the company's links, and stores the draft untagged.
|
||||
pub := &fakePub{}
|
||||
tags := utm.NewTagger([]string{"acme.example"})
|
||||
got, err := Publish(context.Background(), d, Publishers{ChannelLinkedIn: pub}, tags, soon.ID)
|
||||
got, err := Publish(context.Background(), d, ChannelPublishers{ChannelLinkedIn: pub}, tags, soon.ID)
|
||||
if err != nil || got.Status != StatusPublished {
|
||||
t.Fatalf("publish scheduled: %+v, %v", got, err)
|
||||
}
|
||||
@@ -405,7 +405,7 @@ func TestLinkedInAuthor(t *testing.T) {
|
||||
t.Error("an unknown author was taken")
|
||||
}
|
||||
pub := &fakePub{}
|
||||
if _, err := Publish(ctx, d, Publishers{ChannelLinkedIn: pub}, nil, li.ID); err != nil {
|
||||
if _, err := Publish(ctx, d, ChannelPublishers{ChannelLinkedIn: pub}, nil, li.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !pub.got.AsPage {
|
||||
@@ -419,7 +419,7 @@ func TestLinkedInAuthor(t *testing.T) {
|
||||
if err := SetLinkedInAs(d, dr.ID, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
Publish(ctx, d, Publishers{ChannelLinkedIn: pub}, nil, dr.ID)
|
||||
Publish(ctx, d, ChannelPublishers{ChannelLinkedIn: pub}, nil, dr.ID)
|
||||
}
|
||||
}
|
||||
if pub.got.AsPage {
|
||||
|
||||
Reference in New Issue
Block a user