Example #1
0
func (self *channelAPI) Blob_Permission(perma grapher.PermaNode, permission grapher.PermissionNode) {
	mutJson := map[string]interface{}{"perma": perma.BlobRef(), "seq": permission.SequenceNumber(), "type": "permission", "user": permission.UserName(), "allow": permission.AllowBits(), "deny": permission.DenyBits(), "blobref": permission.BlobRef()}
	switch permission.Action() {
	case grapher.PermAction_Invite:
		mutJson["action"] = "invite"
	case grapher.PermAction_Expel:
		mutJson["action"] = "expel"
	case grapher.PermAction_Change:
		mutJson["action"] = "change"
	default:
		panic("Unknown action")
	}
	schema, err := json.Marshal(mutJson)
	if err != nil {
		panic(err.String())
	}
	if self.bufferOnly {
		self.messageBuffer = append(self.messageBuffer, string(schema))
	} else {
		err = self.forwardToFollowers(perma.BlobRef(), string(schema))
	}
	if err != nil {
		log.Printf("Err Forward: %v", err)
	}
}
Example #2
0
func (self *dummyAPI) Signal_ReceivedInvitation(perma grapher.PermaNode, permission grapher.PermissionNode) {
	log.Printf("APP %v: Received Invitation", self.userID)
	// Automatically accept the invitation
	_, err := self.grapher.CreateKeepBlob(perma.BlobRef(), permission.BlobRef())
	if err != nil {
		self.t.Fatal(err.String())
	}
}
Example #3
0
func (self *channelAPI) Blob_Keep(perma grapher.PermaNode, permission grapher.PermissionNode, keep grapher.KeepNode) {
	mutJson := map[string]interface{}{"perma": perma.BlobRef(), "seq": keep.SequenceNumber(), "type": "keep", "signer": keep.Signer(), "mimetype": perma.MimeType()}
	if permission != nil {
		mutJson["permission"] = permission.SequenceNumber()
	}
	schema, err := json.Marshal(mutJson)
	if err != nil {
		panic(err.String())
	}
	message := string(schema)
	if self.bufferOnly {
		self.messageBuffer = append(self.messageBuffer, string(schema))
	} else {
		self.forwardToUser(keep.Signer(), message)
		err = self.forwardToFollowers(perma.BlobRef(), message)
	}
	if err != nil {
		log.Printf("Err Forward: %v", err)
	}
}
Example #4
0
func (self *channelAPI) Signal_ReceivedInvitation(perma grapher.PermaNode, permission grapher.PermissionNode) {
	// TODO: Compute digest
	var digest = "Untitled page"
	msgJson := map[string]interface{}{"perma": perma.BlobRef(), "type": "invitation", "signer": permission.Signer(), "permission": permission.BlobRef(), "digest": digest}
	fillInboxItem(self.store, perma.BlobRef(), int64(0), msgJson)
	schema, err := json.Marshal(msgJson)
	if err != nil {
		panic(err.String())
	}
	if self.bufferOnly {
		self.messageBuffer = append(self.messageBuffer, string(schema))
	} else {
		if perma.MimeType() == "application/x-lightwave-page" {
			addToInbox(self.c, permission.UserName(), perma.BlobRef(), 0)
		}
		err = self.forwardToUser(permission.UserName(), string(schema))
	}
	if err != nil {
		log.Printf("Err Forward: %v", err)
	}

	// Automatically accept the invitation
	//  self.grapher.CreateKeepBlob(perma.BlobRef(), permission.BlobRef())
}
Example #5
0
func (self *channelAPI) Signal_AcceptedInvitation(perma grapher.PermaNode, permission grapher.PermissionNode, keep grapher.KeepNode) {
	msgJson := map[string]interface{}{"perma": perma.BlobRef(), "type": "accept", "signer": permission.Signer(), "permission": permission.BlobRef()}
	schema, err := json.Marshal(msgJson)
	if err != nil {
		panic(err.String())
	}
	if self.bufferOnly {
		self.messageBuffer = append(self.messageBuffer, string(schema))
	} else {
		err = self.forwardToUser(keep.Signer(), string(schema))
	}
	if err != nil {
		log.Printf("Err Forward: %v", err)
	}
}