statamic/collaboration

No connection for Global content

Opened this issue · 4 comments

It seems collaboration does not work for Global content. Perhaps this is because the content is structured differently and stored in the data array?

Screen Shot 2021-08-10 at 4 02 53 pm

To expand a little bit on this, the auth ajax request throws an 403 error.

Hi, as a workaround, put this in the boot method of any service provider:

Broadcast::channel('globals.{id}.{site}', function ($user, $id, $site) {
    return [
        'name' => $user->name(),
        'id' => $user->id(),
        'title' => $user->title(),
        'email' => $user->email(),
        'avatar' => $user->avatar(),
        'initials' => $user->initials(),
    ];
});
theutz commented

Running into this problem, too, but the workaround doesn't seem to be working.

theutz commented

Running into this problem, too, but the workaround doesn't seem to be working.

Upon further investigation, it seems that the front-end is looking for a channel with four segments: globals.{set}.{id}.{site}. I assume, at least, that this is what each of the segments mean.

- Broadcast::channel('globals.{id}.{site}', function ($user, $id, $site) {
+ Broadcast::channel('globals.{set}.{id}.{site}', function ($user, $set, $id, $site) {

So, to updated @ben182 's helpful comment from before, you might need to put the following in routes/channels.php if you have it, or in the boot method of the BroadcastServiceProvider:

Broadcast::channel('globals.{set}.{id}.{site}', function ($user, $set, $id, $site) {
    return [
        'name' => $user->name(),
        'id' => $user->id(),
        'title' => $user->title(),
        'email' => $user->email(),
        'avatar' => $user->avatar(),
        'initials' => $user->initials(),
    ];
});