Skip to content

Commit

Permalink
Fix #1348 channel_convert_to_public message events (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Oct 15, 2024
1 parent 83b8e1b commit e033580
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.slack.api.model.event;

import lombok.Data;

/**
* https://api.slack.com/events/message/channel_convert_to_public
*/
@Data
public class MessageChannelConvertToPublicEvent implements Event {

public static final String TYPE_NAME = "message";
public static final String SUBTYPE_NAME = "channel_convert_to_public";

private final String type = TYPE_NAME;
private final String subtype = SUBTYPE_NAME;

private String user;
private String text;
private String channel;
private String ts;
private String eventTs;
private String channelType; // "channel"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package test_locally.api.model.event;

import com.slack.api.model.event.MessageChannelConvertToPublicEvent;
import org.junit.Test;
import test_locally.unit.GsonFactory;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class MessageChannelConvertToPublicEventTest {

@Test
public void typeName() {
assertThat(MessageChannelConvertToPublicEvent.TYPE_NAME, is("message"));
assertThat(MessageChannelConvertToPublicEvent.SUBTYPE_NAME, is("channel_convert_to_public"));
}

@Test
public void deserialize_simple() {
String json = "{\n" +
" \"subtype\": \"channel_convert_to_public\",\n" +
" \"user\": \"W013QGS7BPF\",\n" +
" \"text\": \"made this channel *public*. Any member in this workspace can see and join it.\",\n" +
" \"type\": \"message\",\n" +
" \"ts\": \"1728976211.166339\",\n" +
" \"channel\": \"C07RP9QHR2S\",\n" +
" \"event_ts\": \"1728976211.166339\",\n" +
" \"channel_type\": \"channel\"\n" +
"}";
MessageChannelConvertToPublicEvent event = GsonFactory.createSnakeCase(true, true).fromJson(json, MessageChannelConvertToPublicEvent.class);
assertThat(event.getType(), is("message"));
assertThat(event.getSubtype(), is("channel_convert_to_public"));
assertThat(event.getUser(), is("W013QGS7BPF"));
}

@Test
public void deserialize_api_document() {
String json = "{\n" +
" \"type\": \"message\",\n" +
" \"subtype\": \"channel_convert_to_public\",\n" +
" \"ts\": \"1723680078.026719\",\n" +
" \"text\": \"Made this channel public. Any member in this workspace can see and join it.\",\n" +
" \"user\": \"U123ABC456\",\n" +
" \"channel\": \"C123ABC456\",\n" +
" \"event_ts\": \"1614215651.001300\",\n" +
" \"channel_type\": \"channel\"\n" +
"}";
MessageChannelConvertToPublicEvent event = GsonFactory.createSnakeCase(true, true).fromJson(json, MessageChannelConvertToPublicEvent.class);
assertThat(event.getType(), is("message"));
assertThat(event.getSubtype(), is("channel_convert_to_public"));
assertThat(event.getUser(), is("U123ABC456"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.slack.api.app_backend.events.handler;

import com.slack.api.app_backend.events.EventHandler;
import com.slack.api.app_backend.events.payload.MessageChannelConvertToPublicPayload;
import com.slack.api.model.event.MessageChannelConvertToPublicEvent;

public abstract class MessageChannelConvertToPublicHandler extends EventHandler<MessageChannelConvertToPublicPayload> {

@Override
public String getEventType() {
return MessageChannelConvertToPublicEvent.TYPE_NAME;
}

@Override
public String getEventSubtype() {
return MessageChannelConvertToPublicEvent.SUBTYPE_NAME;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.slack.api.app_backend.events.payload;

import com.slack.api.model.event.MessageChannelConvertToPublicEvent;
import lombok.Data;

import java.util.List;

@Data
public class MessageChannelConvertToPublicPayload implements EventsApiPayload<MessageChannelConvertToPublicEvent> {

private String token;
private String enterpriseId;
private String teamId;
private String apiAppId;
private String type;
private List<String> authedUsers;
private List<String> authedTeams;
private List<Authorization> authorizations;
private boolean isExtSharedChannel;
private String eventId;
private Integer eventTime;
private String eventContext;

private MessageChannelConvertToPublicEvent event;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.slack.api.app_backend.events.payload;

import com.slack.api.model.event.SharedChannelInviteReceivedEvent;
import com.slack.api.model.event.TeamJoinEvent;
import lombok.Data;

import java.util.List;
Expand Down

0 comments on commit e033580

Please sign in to comment.