Skip to content

Commit

Permalink
report topic's channel status to users
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Aug 5, 2021
1 parent 2a5851a commit 89db1e7
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 273 deletions.
449 changes: 229 additions & 220 deletions pbx/model.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pbx/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ message TopicDesc {
string state = 12;
int64 state_at = 13;
bytes trusted = 14;
bool is_chan = 17; // 17!

// P2P only: other user's last online timestamp & user agent
int64 last_seen_time = 15;
Expand Down Expand Up @@ -362,7 +363,6 @@ message DelValues {
repeated SeqRange del_seq = 2;
}


// {ctrl} message
message ServerCtrl {
string id = 1;
Expand Down
111 changes: 59 additions & 52 deletions py_grpc/tinode_grpc/model_pb2.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions server/datamodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ type MsgTopicDesc struct {
// If the group topic is online.
Online bool `json:"online,omitempty"`

// If the topic can be accessed as a channel
IsChan bool `json:"chan,omitempty"`

// P2P other user's last online timestamp & user agent
LastSeen *MsgLastSeenInfo `json:"seen,omitempty"`

Expand Down
1 change: 1 addition & 0 deletions server/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ func replyOfflineTopicGetDesc(sess *Session, msg *ClientComMessage) {
desc.UpdatedAt = &stopic.UpdatedAt
desc.Public = stopic.Public
desc.Trusted = stopic.Trusted
desc.IsChan = stopic.UseBt
if stopic.Owner == msg.AsUser {
desc.DefaultAcs = &MsgDefaultAcsMode{
Auth: stopic.Access.Auth.String(),
Expand Down
2 changes: 2 additions & 0 deletions server/pbconverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ func pbTopicDescSerialize(desc *MsgTopicDesc) *pbx.TopicDesc {
UpdatedAt: timeToInt64(desc.UpdatedAt),
TouchedAt: timeToInt64(desc.TouchedAt),
State: desc.State,
IsChan: desc.IsChan,
Defacs: pbDefaultAcsSerialize(desc.DefaultAcs),
Acs: pbAccessModeSerialize(desc.Acs),
SeqId: int32(desc.SeqId),
Expand All @@ -811,6 +812,7 @@ func pbTopicDescDeserialize(desc *pbx.TopicDesc) *MsgTopicDesc {
UpdatedAt: int64ToTime(desc.GetUpdatedAt()),
TouchedAt: int64ToTime(desc.GetTouchedAt()),
State: desc.GetState(),
IsChan: desc.GetIsChan(),
DefaultAcs: pbDefaultAcsDeserialize(desc.GetDefacs()),
Acs: pbAccessModeDeserialize(desc.GetAcs()),
SeqId: int(desc.SeqId),
Expand Down
2 changes: 2 additions & 0 deletions server/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,8 @@ func (t *Topic) replyGetDesc(sess *Session, asUid types.Uid, asChan bool, opts *

if t.cat == types.TopicCatMe {
full = true
} else if t.cat == types.TopicCatGrp {
desc.IsChan = t.isChan
}

if ifUpdated {
Expand Down

0 comments on commit 89db1e7

Please sign in to comment.