Session subscribed to a topic, created == true if topic was just created and {pres} needs to be announced
(msg *ClientComMessage)
| 648 | |
| 649 | // Session subscribed to a topic, created == true if topic was just created and {pres} needs to be announced |
| 650 | func (t *Topic) handleSubscription(msg *ClientComMessage) error { |
| 651 | asUid := types.ParseUserId(msg.AsUser) |
| 652 | authLevel := auth.Level(msg.AuthLvl) |
| 653 | asChan, err := t.verifyChannelAccess(msg.Original) |
| 654 | if err != nil { |
| 655 | // User should not be able to address non-channel topic as channel. |
| 656 | msg.sess.queueOut(ErrNotFoundReply(msg, types.TimeNow())) |
| 657 | return err |
| 658 | } |
| 659 | |
| 660 | if err := t.subscriptionReply(asChan, msg); err != nil { |
| 661 | return err |
| 662 | } |
| 663 | |
| 664 | msgsub := msg.Sub |
| 665 | getWhat := 0 |
| 666 | if msgsub.Get != nil { |
| 667 | getWhat = parseMsgClientMeta(msgsub.Get.What) |
| 668 | } |
| 669 | if getWhat&constMsgMetaDesc != 0 { |
| 670 | // Send get.desc as a {meta} packet. |
| 671 | if err := t.replyGetDesc(msg.sess, asUid, asChan, msgsub.Get.Desc, msg); err != nil { |
| 672 | logs.Warn.Printf("topic[%s] handleSubscription Get.Desc failed: %v sid=%s", t.name, err, msg.sess.sid) |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | if getWhat&constMsgMetaSub != 0 { |
| 677 | // Send get.sub response as a separate {meta} packet |
| 678 | if err := t.replyGetSub(msg.sess, asUid, authLevel, asChan, msg); err != nil { |
| 679 | logs.Warn.Printf("topic[%s] handleSubscription Get.Sub failed: %v sid=%s", t.name, err, msg.sess.sid) |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | if getWhat&constMsgMetaTags != 0 { |
| 684 | // Send get.tags response as a separate {meta} packet |
| 685 | if err := t.replyGetTags(msg.sess, asUid, msg); err != nil { |
| 686 | logs.Warn.Printf("topic[%s] handleSubscription Get.Tags failed: %v sid=%s", t.name, err, msg.sess.sid) |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | if getWhat&constMsgMetaCred != 0 { |
| 691 | // Send get.tags response as a separate {meta} packet |
| 692 | if err := t.replyGetCreds(msg.sess, asUid, msg); err != nil { |
| 693 | logs.Warn.Printf("topic[%s] handleSubscription Get.Cred failed: %v sid=%s", t.name, err, msg.sess.sid) |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | if getWhat&constMsgMetaAux != 0 { |
| 698 | // Send get.aux response as a separate {meta} packet |
| 699 | if err := t.replyGetAux(msg.sess, asUid, msg); err != nil { |
| 700 | logs.Warn.Printf("topic[%s] handleSubscription Get.Aux failed: %v sid=%s", t.name, err, msg.sess.sid) |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | if getWhat&constMsgMetaData != 0 { |
| 705 | // Send get.data response as {data} packets |
| 706 | if err := t.replyGetData(msg.sess, asUid, asChan, msgsub.Get.Data, msg); err != nil { |
| 707 | logs.Warn.Printf("topic[%s] handleSubscription Get.Data failed: %v sid=%s", t.name, err, msg.sess.sid) |
no test coverage detected